|
LLVM 24.0.0git
|
Provide access to the Option info table. More...
#include "llvm/Option/OptTable.h"
Classes | |
| struct | HelpTextVariant |
| Help text that replaces Info::HelpTextOffset when the visibility mask being printed intersects Visibility. More... | |
| struct | Info |
| Entry for a single option instance in the option data table. More... | |
| struct | InfoExtra |
| Fields few options set. More... | |
| struct | SubCommand |
| Represents a subcommand and its options in the option table. More... | |
| struct | Tables |
| The tables TableGen emits for an option set under OPTTABLE_CODE. More... | |
Public Types | |
| using | ValuesCodeFnTy = StringRef (*)(unsigned) |
| Values of options declared with TableGen ValuesCode: only the generated code knows them, so they cannot go in the string table. | |
Public Member Functions | |
| bool | isValidForSubCommand (const Info *CandidateInfo, StringRef SubCommand) const |
| virtual | ~OptTable () |
| const StringTable & | getStrTable () const |
| Return the string table used for option names. | |
| ArrayRef< SubCommand > | getSubCommands () const |
| ArrayRef< StringTable::Offset > | getPrefixesTable () const |
| Return the prefixes table used for option names. | |
| unsigned | getNumOptions () const |
| Return the total number of option classes. | |
| unsigned | getOptionID (const Info &I) const |
| const Option | getOption (OptSpecifier Opt) const |
| Get the given Opt's Option instance, lazily creating it if necessary. | |
| StringRef | getOptionName (OptSpecifier id) const |
| Lookup the name of the given option. | |
| StringRef | getOptionPrefix (OptSpecifier id) const |
| Lookup the prefix of the given option. | |
| void | appendOptionPrefixes (OptSpecifier id, SmallVectorImpl< StringRef > &Prefixes) const |
| StringRef | getOptionPrefixedName (OptSpecifier id) const |
| Lookup the prefixed name of the given option. | |
| unsigned | getOptionKind (OptSpecifier id) const |
| Get the kind of the given option. | |
| unsigned | getOptionGroupID (OptSpecifier id) const |
| Get the group id for the given option. | |
| StringRef | getOptionHelpText (OptSpecifier id) const |
| Get the help text to use to describe this option. | |
| StringRef | getOptionHelpText (OptSpecifier id, Visibility VisibilityMask) const |
| StringRef | getOptionMetaVar (OptSpecifier id) const |
| Get the meta-variable name to use when describing this options values in the help text. | |
| const char * | getOptionAliasArgs (OptSpecifier id) const |
| Get the alias arguments as a \0 separated list, e.g. "foo\0bar\0". | |
| void | setInitialOptionsFromEnvironment (const char *E) |
| Specify the environment variable where initial options should be read. | |
| void | setGroupedShortOptions (bool Value) |
| Support grouped short options. e.g. -ab represents -a -b. | |
| void | setDashDashParsing (bool Value) |
| Set whether "--" stops option parsing and treats all subsequent arguments as positional. | |
| std::vector< std::string > | suggestValueCompletions (StringRef Option, StringRef Arg) const |
| Find possible value for given flags. | |
| std::vector< std::string > | findByPrefix (StringRef Cur, Visibility VisibilityMask, unsigned int DisableFlags) const |
| Find flags from OptTable which starts with Cur. | |
| unsigned | findNearest (StringRef Option, std::string &NearestString, Visibility VisibilityMask=Visibility(), unsigned MinimumLength=4, unsigned MaximumDistance=UINT_MAX) const |
| Find the OptTable option that most closely matches the given string. | |
| unsigned | findNearest (StringRef Option, std::string &NearestString, unsigned FlagsToInclude, unsigned FlagsToExclude=0, unsigned MinimumLength=4, unsigned MaximumDistance=UINT_MAX) const |
| bool | findExact (StringRef Option, std::string &ExactString, Visibility VisibilityMask=Visibility()) const |
| bool | findExact (StringRef Option, std::string &ExactString, unsigned FlagsToInclude, unsigned FlagsToExclude=0) const |
| std::unique_ptr< Arg > | ParseOneArg (const ArgList &Args, unsigned &Index, Visibility VisibilityMask=Visibility()) const |
| Parse a single argument; returning the new argument and updating Index. | |
| std::unique_ptr< Arg > | ParseOneArg (const ArgList &Args, unsigned &Index, unsigned FlagsToInclude, unsigned FlagsToExclude) const |
| InputArgList | ParseArgs (ArrayRef< const char * > Args, unsigned &MissingArgIndex, unsigned &MissingArgCount, Visibility VisibilityMask=Visibility()) const |
| Parse an list of arguments into an InputArgList. | |
| InputArgList | ParseArgs (ArrayRef< const char * > Args, unsigned &MissingArgIndex, unsigned &MissingArgCount, unsigned FlagsToInclude, unsigned FlagsToExclude=0) const |
| InputArgList | parseArgs (int Argc, char *const *Argv, OptSpecifier Unknown, StringSaver &Saver, std::function< void(StringRef)> ErrorFn) const |
| A convenience helper which handles optional initial options populated from an environment variable, expands response files recursively and parses options. | |
| void | printHelp (raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden=false, bool ShowAllAliases=false, Visibility VisibilityMask=Visibility(), StringRef SubCommand={}) const |
| Render the help text for an option table. | |
| void | printHelp (raw_ostream &OS, const char *Usage, const char *Title, unsigned FlagsToInclude, unsigned FlagsToExclude, bool ShowAllAliases) const |
Protected Member Functions | |
| OptTable (const Tables &Tables, bool IgnoreCase=false) | |
| void | setValuesCodeFn (ValuesCodeFnTy Fn) |
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.
Definition at line 54 of file OptTable.h.
| using llvm::opt::OptTable::ValuesCodeFnTy = StringRef (*)(unsigned) |
Values of options declared with TableGen ValuesCode: only the generated code knows them, so they cannot go in the string table.
The generated table supplies getOptionValuesCode() for this.
Definition at line 66 of file OptTable.h.
Definition at line 76 of file OptTable.cpp.
|
virtualdefault |
|
inline |
Definition at line 299 of file OptTable.h.
References I.
| std::vector< std::string > OptTable::findByPrefix | ( | StringRef | Cur, |
| Visibility | VisibilityMask, | ||
| unsigned int | DisableFlags ) const |
Find flags from OptTable which starts with Cur.
| [in] | Cur | - String prefix that all returned flags need |
Definition at line 210 of file OptTable.cpp.
References I, and starts_with().
|
inline |
Definition at line 415 of file OptTable.h.
References findNearest().
|
inline |
Definition at line 410 of file OptTable.h.
References findNearest().
| unsigned OptTable::findNearest | ( | StringRef | Option, |
| std::string & | NearestString, | ||
| unsigned | FlagsToInclude, | ||
| unsigned | FlagsToExclude = 0, | ||
| unsigned | MinimumLength = 4, | ||
| unsigned | MaximumDistance = UINT_MAX ) const |
Definition at line 245 of file OptTable.cpp.
References llvm::opt::OptTable::Info::Flags.
| unsigned OptTable::findNearest | ( | StringRef | Option, |
| std::string & | NearestString, | ||
| Visibility | VisibilityMask = Visibility(), | ||
| unsigned | MinimumLength = 4, | ||
| unsigned | MaximumDistance = UINT_MAX ) const |
Find the OptTable option that most closely matches the given string.
| [in] | 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". |
| [out] | NearestString | - The nearest option string found in the OptTable. |
| [in] | VisibilityMask | - Only include options with any of these visibility flags set. |
| [in] | MinimumLength | - Don't find options shorter than this length. For example, a minimum length of 3 prevents "-x" from being considered near to "-S". |
| [in] | MaximumDistance | - Don't find options whose distance is greater than this value. |
Definition at line 234 of file OptTable.cpp.
References llvm::opt::OptTable::Info::Visibility.
Referenced by findExact(), findExact(), and parseArgs().
|
inline |
Return the total number of option classes.
Definition at line 275 of file OptTable.h.
Referenced by getOption().
| const Option OptTable::getOption | ( | OptSpecifier | Opt | ) | const |
Get the given Opt's Option instance, lazily creating it if necessary.
Definition at line 135 of file OptTable.cpp.
References assert(), llvm::opt::OptSpecifier::getID(), and getNumOptions().
Referenced by getOptionHelpName().
|
inline |
Get the alias arguments as a \0 separated list, e.g. "foo\0bar\0".
Definition at line 340 of file OptTable.h.
|
inline |
Get the group id for the given option.
Definition at line 316 of file OptTable.h.
Referenced by getOptionHelpGroup().
|
inline |
Get the help text to use to describe this option.
Definition at line 321 of file OptTable.h.
References getOptionHelpText().
Referenced by getOptionHelpGroup(), and getOptionHelpText().
|
inline |
Definition at line 328 of file OptTable.h.
Definition at line 277 of file OptTable.h.
References I.
|
inline |
Get the kind of the given option.
Definition at line 311 of file OptTable.h.
|
inline |
Get the meta-variable name to use when describing this options values in the help text.
Definition at line 335 of file OptTable.h.
Referenced by getOptionHelpName().
|
inline |
Lookup the name of the given option.
Definition at line 288 of file OptTable.h.
|
inline |
|
inline |
Lookup the prefixed name of the given option.
Definition at line 306 of file OptTable.h.
|
inline |
Return the prefixes table used for option names.
Definition at line 270 of file OptTable.h.
|
inline |
Return the string table used for option names.
Definition at line 265 of file OptTable.h.
|
inline |
Definition at line 267 of file OptTable.h.
|
inline |
Definition at line 161 of file OptTable.h.
References assert(), C(), llvm::find_if(), and llvm::is_contained().
| InputArgList OptTable::ParseArgs | ( | ArrayRef< const char * > | Args, |
| unsigned & | MissingArgIndex, | ||
| unsigned & | MissingArgCount, | ||
| unsigned | FlagsToInclude, | ||
| unsigned | FlagsToExclude = 0 ) const |
Definition at line 508 of file OptTable.cpp.
References llvm::opt::Option::hasFlag().
| InputArgList OptTable::ParseArgs | ( | ArrayRef< const char * > | Args, |
| unsigned & | MissingArgIndex, | ||
| unsigned & | MissingArgCount, | ||
| Visibility | VisibilityMask = Visibility() ) const |
Parse an list of arguments into an InputArgList.
The resulting InputArgList will reference the strings in [ArgBegin, 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 MissingArgCount will be non-zero.
| MissingArgIndex | - On error, the index of the option which could not be parsed. |
| MissingArgCount | - On error, the number of missing options. |
| VisibilityMask | - Only include options with any of these visibility flags set. |
Definition at line 497 of file OptTable.cpp.
References llvm::opt::Option::hasVisibilityFlag().
Referenced by parseArgs().
| InputArgList OptTable::parseArgs | ( | int | Argc, |
| char *const * | Argv, | ||
| OptSpecifier | Unknown, | ||
| StringSaver & | Saver, | ||
| std::function< void(StringRef)> | ErrorFn ) const |
A convenience helper which handles optional initial options populated from an environment variable, expands response files recursively and parses options.
| ErrorFn | - Called on a formatted error message for missing arguments or unknown options. |
Definition at line 579 of file OptTable.cpp.
References A(), llvm::ArrayRef(), llvm::cl::expandResponseFiles(), findNearest(), ParseArgs(), and llvm::Unknown.
| std::unique_ptr< Arg > OptTable::ParseOneArg | ( | const ArgList & | Args, |
| unsigned & | Index, | ||
| unsigned | FlagsToInclude, | ||
| unsigned | FlagsToExclude ) const |
Definition at line 420 of file OptTable.cpp.
References llvm::opt::Option::hasFlag().
| std::unique_ptr< Arg > OptTable::ParseOneArg | ( | const ArgList & | Args, |
| unsigned & | Index, | ||
| Visibility | VisibilityMask = Visibility() ) const |
Parse a single argument; returning the new argument and updating Index.
| [in,out] | Index | - The current parsing position in the argument string list; on return this will be the index of the next argument string to parse. |
| [in] | VisibilityMask | - Only include options with any of these visibility flags set. |
Definition at line 413 of file OptTable.cpp.
References llvm::opt::Option::hasVisibilityFlag().
| void OptTable::printHelp | ( | raw_ostream & | OS, |
| const char * | Usage, | ||
| const char * | Title, | ||
| bool | ShowHidden = false, | ||
| bool | ShowAllAliases = false, | ||
| Visibility | VisibilityMask = Visibility(), | ||
| StringRef | SubCommand = {} ) const |
Render the help text for an option table.
| OS | - The stream to write the help text to. |
| Usage | - USAGE: Usage |
| Title | - OVERVIEW: Title |
| VisibilityMask | - Only in Visibility VisibilityMask,clude options with any of these visibility flags set. |
| ShowHidden | - If true, display options marked as HelpHidden |
| 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. |
Definition at line 713 of file OptTable.cpp.
References llvm::opt::OptTable::Info::Visibility.
| void OptTable::printHelp | ( | raw_ostream & | OS, |
| const char * | Usage, | ||
| const char * | Title, | ||
| unsigned | FlagsToInclude, | ||
| unsigned | FlagsToExclude, | ||
| bool | ShowAllAliases ) const |
Definition at line 725 of file OptTable.cpp.
References llvm::opt::HelpHidden.
|
inline |
Set whether "--" stops option parsing and treats all subsequent arguments as positional.
E.g. – -a -b gives two positional inputs.
Definition at line 352 of file OptTable.h.
|
inline |
Support grouped short options. e.g. -ab represents -a -b.
Definition at line 348 of file OptTable.h.
Specify the environment variable where initial options should be read.
Definition at line 345 of file OptTable.h.
References E().
|
inlineprotected |
Definition at line 259 of file OptTable.h.
| std::vector< std::string > OptTable::suggestValueCompletions | ( | StringRef | Option, |
| StringRef | Arg ) const |
Find possible value for given flags.
This is used for shell autocompletion.
| [in] | Option | - Key flag like "-stdlib=" when "-stdlib=l" was passed to clang. |
| [in] | Arg | - Value which we want to autocomplete like "l" when "-stdlib=l" was passed to clang. |
Definition at line 187 of file OptTable.cpp.
References I, optionMatches(), and llvm::Values.