class CommonOptionsParser
Declaration
class CommonOptionsParser { /* full declaration omitted */ };
Description
A parser for options common to all command-line Clang tools. Parses a common subset of command-line arguments, locates and loads a compilation commands database and runs a tool with user-specified action. It also contains a help message for the common command-line options. An example of usage:
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:65
Member Variables
- private std::unique_ptr<CompilationDatabase> Compilations
- private std::vector<std::string> SourcePathList
- private clang::tooling::ArgumentsAdjuster Adjuster
- public static const char* const HelpMessage
Method Overview
- protected CommonOptionsParser(int & argc, const char ** argv, llvm::cl::OptionCategory & Category, llvm::cl::NumOccurrencesFlag OccurrencesFlag = llvm::cl::OneOrMore, const char * Overview = nullptr)
- private CommonOptionsParser()
- public static llvm::Expected<CommonOptionsParser> create(int & argc, const char ** argv, llvm::cl::OptionCategory & Category, llvm::cl::NumOccurrencesFlag OccurrencesFlag = llvm::cl::OneOrMore, const char * Overview = nullptr)
- public clang::tooling::ArgumentsAdjuster getArgumentsAdjuster()
- public clang::tooling::CompilationDatabase & getCompilations()
- public const std::vector<std::string> & getSourcePathList() const
- private llvm::Error init(int & argc, const char ** argv, llvm::cl::OptionCategory & Category, llvm::cl::NumOccurrencesFlag OccurrencesFlag, const char * Overview)
Methods
¶CommonOptionsParser(
int& argc,
const char** argv,
llvm::cl::OptionCategory& Category,
llvm::cl::NumOccurrencesFlag OccurrencesFlag =
llvm::cl::OneOrMore,
const char* Overview = nullptr)
CommonOptionsParser(
int& argc,
const char** argv,
llvm::cl::OptionCategory& Category,
llvm::cl::NumOccurrencesFlag OccurrencesFlag =
llvm::cl::OneOrMore,
const char* Overview = nullptr)
Description
Parses command-line, initializes a compilation database. This constructor can change argc and argv contents, e.g. consume command-line options used for creating FixedCompilationDatabase. All options not belonging to \p Category become hidden. It also allows calls to set the required number of positional parameters.
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:76
Parameters
- int& argc
- const char** argv
- llvm::cl::OptionCategory& Category
- llvm::cl::NumOccurrencesFlag OccurrencesFlag = llvm::cl::OneOrMore
- const char* Overview = nullptr
¶CommonOptionsParser()
CommonOptionsParser()
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:106
¶static llvm::Expected<CommonOptionsParser> create(
int& argc,
const char** argv,
llvm::cl::OptionCategory& Category,
llvm::cl::NumOccurrencesFlag OccurrencesFlag =
llvm::cl::OneOrMore,
const char* Overview = nullptr)
static llvm::Expected<CommonOptionsParser> create(
int& argc,
const char** argv,
llvm::cl::OptionCategory& Category,
llvm::cl::NumOccurrencesFlag OccurrencesFlag =
llvm::cl::OneOrMore,
const char* Overview = nullptr)
Description
A factory method that is similar to the above constructor, except this returns an error instead exiting the program on error.
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:85
Parameters
- int& argc
- const char** argv
- llvm::cl::OptionCategory& Category
- llvm::cl::NumOccurrencesFlag OccurrencesFlag = llvm::cl::OneOrMore
- const char* Overview = nullptr
¶clang::tooling::ArgumentsAdjuster
getArgumentsAdjuster()
clang::tooling::ArgumentsAdjuster
getArgumentsAdjuster()
Description
Returns the argument adjuster calculated from "--extra-arg" and
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:101
¶clang::tooling::CompilationDatabase&
getCompilations()
clang::tooling::CompilationDatabase&
getCompilations()
Description
Returns a reference to the loaded compilations database.
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:90
¶const std::vector<std::string>&
getSourcePathList() const
const std::vector<std::string>&
getSourcePathList() const
Description
Returns a list of source file paths to process.
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:95
¶llvm::Error init(
int& argc,
const char** argv,
llvm::cl::OptionCategory& Category,
llvm::cl::NumOccurrencesFlag OccurrencesFlag,
const char* Overview)
llvm::Error init(
int& argc,
const char** argv,
llvm::cl::OptionCategory& Category,
llvm::cl::NumOccurrencesFlag OccurrencesFlag,
const char* Overview)
Declared at: clang/include/clang/Tooling/CommonOptionsParser.h:108
Parameters
- int& argc
- const char** argv
- llvm::cl::OptionCategory& Category
- llvm::cl::NumOccurrencesFlag OccurrencesFlag
- const char* Overview