class OptTable
Declaration
class OptTable { /* full declaration omitted */ };
Description
Provide access to the Option info table. The OptTable class provides a layer of indirection which allows Option instance to be created lazily. In the common case, only a few options will be needed at runtime; the OptTable class maintains enough information to parse command lines without instantiating Options, while letting other parts of the driver still use Option instances where convenient.
Declared at: llvm/include/llvm/Option/OptTable.h:38
Method Overview
- protected OptTable(ArrayRef<llvm::opt::OptTable::Info> OptionInfos, bool IgnoreCase = false)
- public llvm::opt::InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned int & MissingArgIndex, unsigned int & MissingArgCount, unsigned int FlagsToInclude = 0, unsigned int FlagsToExclude = 0) const
- public llvm::opt::Arg * ParseOneArg(const llvm::opt::ArgList & Args, unsigned int & Index, unsigned int FlagsToInclude = 0, unsigned int FlagsToExclude = 0) const
- public void PrintHelp(llvm::raw_ostream & OS, const char * Usage, const char * Title, bool ShowHidden = false, bool ShowAllAliases = false) const
- public void PrintHelp(llvm::raw_ostream & OS, const char * Usage, const char * Title, unsigned int FlagsToInclude, unsigned int FlagsToExclude, bool ShowAllAliases) const
- public bool addValues(const char * Option, const char * Values)
- public std::vector<std::string> findByPrefix(llvm::StringRef Cur, unsigned short DisableFlags) const
- public unsigned int findNearest(llvm::StringRef Option, std::string & NearestString, unsigned int FlagsToInclude = 0, unsigned int FlagsToExclude = 0, unsigned int MinimumLength = 4) const
- public unsigned int getNumOptions() const
- public const llvm::opt::Option getOption(llvm::opt::OptSpecifier Opt) const
- public unsigned int getOptionGroupID(llvm::opt::OptSpecifier id) const
- public const char * getOptionHelpText(llvm::opt::OptSpecifier id) const
- public unsigned int getOptionKind(llvm::opt::OptSpecifier id) const
- public const char * getOptionMetaVar(llvm::opt::OptSpecifier id) const
- public const char * getOptionName(llvm::opt::OptSpecifier id) const
- public std::vector<std::string> suggestValueCompletions(llvm::StringRef Option, llvm::StringRef Arg) const
- public ~OptTable()
Methods
¶OptTable(ArrayRef<llvm::opt::OptTable::Info>
OptionInfos,
bool IgnoreCase = false)
OptTable(ArrayRef<llvm::opt::OptTable::Info>
OptionInfos,
bool IgnoreCase = false)
Declared at: llvm/include/llvm/Option/OptTable.h:83
Parameters
- ArrayRef<llvm::opt::OptTable::Info> OptionInfos
- bool IgnoreCase = false
¶llvm::opt::InputArgList ParseArgs(
ArrayRef<const char*> Args,
unsigned int& MissingArgIndex,
unsigned int& MissingArgCount,
unsigned int FlagsToInclude = 0,
unsigned int FlagsToExclude = 0) const
llvm::opt::InputArgList ParseArgs(
ArrayRef<const char*> Args,
unsigned int& MissingArgIndex,
unsigned int& MissingArgCount,
unsigned int FlagsToInclude = 0,
unsigned int FlagsToExclude = 0) const
Description
Parse an list of arguments into an InputArgList. The resulting InputArgList will reference the strings in [\p ArgBegin, \p ArgEnd), and their lifetime should extend past that of the returned InputArgList. The only error that can occur in this routine is if an argument is missing values; in this case \p MissingArgCount will be non-zero.
Declared at: llvm/include/llvm/Option/OptTable.h:212
Parameters
- ArrayRef<const char*> Args
- unsigned int& MissingArgIndex
- - On error, the index of the option which could not be parsed.
- unsigned int& MissingArgCount
- - On error, the number of missing options.
- unsigned int FlagsToInclude = 0
- - Only parse options with any of these flags. Zero is the default which includes all flags.
- unsigned int FlagsToExclude = 0
- - Don't parse options with this flag. Zero is the default and means exclude nothing.
Returns
An InputArgList; on error this will contain all the options which could be parsed.
¶llvm::opt::Arg* ParseOneArg(
const llvm::opt::ArgList& Args,
unsigned int& Index,
unsigned int FlagsToInclude = 0,
unsigned int FlagsToExclude = 0) const
llvm::opt::Arg* ParseOneArg(
const llvm::opt::ArgList& Args,
unsigned int& Index,
unsigned int FlagsToInclude = 0,
unsigned int FlagsToExclude = 0) const
Description
Parse a single argument; returning the new argument and updating Index.
Declared at: llvm/include/llvm/Option/OptTable.h:190
Parameters
- const llvm::opt::ArgList& Args
- unsigned int& Index
- - The current parsing position in the argument string list; on return this will be the index of the next argument string to parse.
- unsigned int FlagsToInclude = 0
- - Only parse options with any of these flags. Zero is the default which includes all flags.
- unsigned int FlagsToExclude = 0
- - Don't parse options with this flag. Zero is the default and means exclude nothing.
Returns
The parsed argument, or 0 if the argument is missing values (in which case Index still points at the conceptual next argument string to parse).
¶void PrintHelp(llvm::raw_ostream& OS,
const char* Usage,
const char* Title,
bool ShowHidden = false,
bool ShowAllAliases = false) const
void PrintHelp(llvm::raw_ostream& OS,
const char* Usage,
const char* Title,
bool ShowHidden = false,
bool ShowAllAliases = false) const
Declared at: llvm/include/llvm/Option/OptTable.h:232
Parameters
- llvm::raw_ostream& OS
- const char* Usage
- const char* Title
- bool ShowHidden = false
- bool ShowAllAliases = false
¶void PrintHelp(llvm::raw_ostream& OS,
const char* Usage,
const char* Title,
unsigned int FlagsToInclude,
unsigned int FlagsToExclude,
bool ShowAllAliases) const
void PrintHelp(llvm::raw_ostream& OS,
const char* Usage,
const char* Title,
unsigned int FlagsToInclude,
unsigned int FlagsToExclude,
bool ShowAllAliases) const
Description
Render the help text for an option table.
Declared at: llvm/include/llvm/Option/OptTable.h:228
Parameters
- llvm::raw_ostream& OS
- - The stream to write the help text to.
- const char* Usage
- - USAGE: Usage
- const char* Title
- - OVERVIEW: Title
- unsigned int FlagsToInclude
- - If non-zero, only include options with any of these flags set.
- unsigned int FlagsToExclude
- - Exclude options with any of these flags set.
- bool ShowAllAliases
- - If true, display all options including aliases that don't have help texts. By default, we display only options that are not hidden and have help texts.
¶bool addValues(const char* Option,
const char* Values)
bool addValues(const char* Option,
const char* Values)
Description
Add Values to Option's Values class
Declared at: llvm/include/llvm/Option/OptTable.h:174
Parameters
- const char* Option
- - Prefix + Name of the flag which Values will be changed. For example, "-analyzer-checker".
- const char* Values
- - String of Values seperated by ",", such as "foo, bar..", where foo and bar is the argument which the Option flag takes
Returns
true in success, and false in fail.
¶std::vector<std::string> findByPrefix(
llvm::StringRef Cur,
unsigned short DisableFlags) const
std::vector<std::string> findByPrefix(
llvm::StringRef Cur,
unsigned short DisableFlags) const
Declared at: llvm/include/llvm/Option/OptTable.h:142
Parameters
- llvm::StringRef Cur
- unsigned short DisableFlags
Returns
The vector of flags which start with Cur.
¶unsigned int findNearest(
llvm::StringRef Option,
std::string& NearestString,
unsigned int FlagsToInclude = 0,
unsigned int FlagsToExclude = 0,
unsigned int MinimumLength = 4) const
unsigned int findNearest(
llvm::StringRef Option,
std::string& NearestString,
unsigned int FlagsToInclude = 0,
unsigned int FlagsToExclude = 0,
unsigned int MinimumLength = 4) const
Description
Find the OptTable option that most closely matches the given string.
Declared at: llvm/include/llvm/Option/OptTable.h:161
Parameters
- llvm::StringRef Option
- - A string, such as "-stdlibs=l", that represents user input of an option that may not exist in the OptTable. Note that the string includes prefix dashes "-" as well as values "=l".
- std::string& NearestString
- - The nearest option string found in the OptTable.
- unsigned int FlagsToInclude = 0
- - Only find options with any of these flags. Zero is the default, which includes all flags.
- unsigned int FlagsToExclude = 0
- - Don't find options with this flag. Zero is the default, and means exclude nothing.
- unsigned int MinimumLength = 4
- - Don't find options shorter than this length. For example, a minimum length of 3 prevents "-x" from being considered near to "-S".
Returns
The edit distance of the nearest string found.
¶unsigned int getNumOptions() const
unsigned int getNumOptions() const
Description
Return the total number of option classes.
Declared at: llvm/include/llvm/Option/OptTable.h:89
¶const llvm::opt::Option getOption(
llvm::opt::OptSpecifier Opt) const
const llvm::opt::Option getOption(
llvm::opt::OptSpecifier Opt) const
Description
Get the given Opt's Option instance, lazily creating it if necessary.
Declared at: llvm/include/llvm/Option/OptTable.h:95
Parameters
Returns
The option, or null for the INVALID option id.
¶unsigned int getOptionGroupID(
llvm::opt::OptSpecifier id) const
unsigned int getOptionGroupID(
llvm::opt::OptSpecifier id) const
Description
Get the group id for the given option.
Declared at: llvm/include/llvm/Option/OptTable.h:108
Parameters
¶const char* getOptionHelpText(
llvm::opt::OptSpecifier id) const
const char* getOptionHelpText(
llvm::opt::OptSpecifier id) const
Description
Get the help text to use to describe this option.
Declared at: llvm/include/llvm/Option/OptTable.h:113
Parameters
¶unsigned int getOptionKind(
llvm::opt::OptSpecifier id) const
unsigned int getOptionKind(
llvm::opt::OptSpecifier id) const
Description
Get the kind of the given option.
Declared at: llvm/include/llvm/Option/OptTable.h:103
Parameters
¶const char* getOptionMetaVar(
llvm::opt::OptSpecifier id) const
const char* getOptionMetaVar(
llvm::opt::OptSpecifier id) const
Description
Get the meta-variable name to use when describing this options values in the help text.
Declared at: llvm/include/llvm/Option/OptTable.h:119
Parameters
¶const char* getOptionName(
llvm::opt::OptSpecifier id) const
const char* getOptionName(
llvm::opt::OptSpecifier id) const
Description
Lookup the name of the given option.
Declared at: llvm/include/llvm/Option/OptTable.h:98
Parameters
¶std::vector<std::string> suggestValueCompletions(
llvm::StringRef Option,
llvm::StringRef Arg) const
std::vector<std::string> suggestValueCompletions(
llvm::StringRef Option,
llvm::StringRef Arg) const
Description
Find possible value for given flags. This is used for shell autocompletion.
Declared at: llvm/include/llvm/Option/OptTable.h:133
Parameters
- llvm::StringRef Option
- - Key flag like "-stdlib=" when "-stdlib=l" was passed to clang.
- llvm::StringRef Arg
- - Value which we want to autocomplete like "l" when "-stdlib=l" was passed to clang.
Returns
The vector of possible values.
¶~OptTable()
~OptTable()
Declared at: llvm/include/llvm/Option/OptTable.h:86