LLVM
8.0.1
|
Provide access to the Option info table. More...
#include "llvm/Option/OptTable.h"
Classes | |
struct | Info |
Entry for a single option instance in the option data table. More... | |
Public Member Functions | |
~OptTable () | |
unsigned | getNumOptions () const |
Return the total number of option classes. More... | |
const Option | getOption (OptSpecifier Opt) const |
Get the given Opt's Option instance, lazily creating it if necessary. More... | |
const char * | getOptionName (OptSpecifier id) const |
Lookup the name of the given option. More... | |
unsigned | getOptionKind (OptSpecifier id) const |
Get the kind of the given option. More... | |
unsigned | getOptionGroupID (OptSpecifier id) const |
Get the group id for the given option. More... | |
const char * | getOptionHelpText (OptSpecifier id) const |
Get the help text to use to describe this option. More... | |
const char * | getOptionMetaVar (OptSpecifier id) const |
Get the meta-variable name to use when describing this options values in the help text. More... | |
std::vector< std::string > | suggestValueCompletions (StringRef Option, StringRef Arg) const |
Find possible value for given flags. More... | |
std::vector< std::string > | findByPrefix (StringRef Cur, unsigned short DisableFlags) const |
Find flags from OptTable which starts with Cur. More... | |
unsigned | findNearest (StringRef Option, std::string &NearestString, unsigned FlagsToInclude=0, unsigned FlagsToExclude=0, unsigned MinimumLength=4) const |
Find the OptTable option that most closely matches the given string. More... | |
bool | addValues (const char *Option, const char *Values) |
Add Values to Option's Values class. More... | |
Arg * | ParseOneArg (const ArgList &Args, unsigned &Index, unsigned FlagsToInclude=0, unsigned FlagsToExclude=0) const |
Parse a single argument; returning the new argument and updating Index. More... | |
InputArgList | ParseArgs (ArrayRef< const char *> Args, unsigned &MissingArgIndex, unsigned &MissingArgCount, unsigned FlagsToInclude=0, unsigned FlagsToExclude=0) const |
Parse an list of arguments into an InputArgList. More... | |
void | PrintHelp (raw_ostream &OS, const char *Usage, const char *Title, unsigned FlagsToInclude, unsigned FlagsToExclude, bool ShowAllAliases) const |
Render the help text for an option table. More... | |
void | PrintHelp (raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden=false, bool ShowAllAliases=false) const |
Protected Member Functions | |
OptTable (ArrayRef< Info > OptionInfos, bool IgnoreCase=false) | |
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 39 of file OptTable.h.
Definition at line 98 of file OptTable.cpp.
References assert(), llvm::StringRef::begin(), llvm::StringMap< ValueTy, AllocatorTy >::begin(), C, llvm::opt::Option::dump(), E, llvm::StringRef::end(), llvm::StringMap< ValueTy, AllocatorTy >::end(), getNumOptions(), getOption(), llvm::opt::Option::GroupClass, I, llvm::opt::OptTable::Info::ID, llvm::opt::Option::InputClass, llvm::StringSet< AllocatorTy >::insert(), llvm::is_contained(), llvm::opt::OptTable::Info::Kind, Kind, llvm_unreachable, P, llvm::cl::Prefix, llvm::opt::Option::UnknownClass, and ~OptTable().
|
default |
Referenced by OptTable().
Add Values to Option's Values class.
[in] | Option | - Prefix + Name of the flag which Values will be changed. For example, "-analyzer-checker". |
[in] | Values | - String of Values seperated by ",", such as "foo, bar..", where foo and bar is the argument which the Option flag takes |
Definition at line 313 of file OptTable.cpp.
References E, I, llvm::tgtok::In, optionMatches(), and llvm::opt::OptTable::Info::Values.
Referenced by getOptionMetaVar().
std::vector< std::string > OptTable::findByPrefix | ( | StringRef | Cur, |
unsigned short | DisableFlags | ||
) | const |
Find flags from OptTable which starts with Cur.
[in] | Cur | - String prefix that all returned flags need |
Definition at line 230 of file OptTable.cpp.
References E, llvm::opt::OptTable::Info::Flags, llvm::opt::OptTable::Info::GroupID, llvm::opt::OptTable::Info::HelpText, I, llvm::tgtok::In, llvm::opt::OptTable::Info::Name, llvm::opt::OptTable::Info::Prefixes, llvm::MipsISD::Ret, and startswith().
Referenced by getOptionMetaVar().
unsigned OptTable::findNearest | ( | StringRef | Option, |
std::string & | NearestString, | ||
unsigned | FlagsToInclude = 0 , |
||
unsigned | FlagsToExclude = 0 , |
||
unsigned | MinimumLength = 4 |
||
) | 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] | FlagsToInclude | - Only find options with any of these flags. Zero is the default, which includes all flags. |
[in] | FlagsToExclude | - Don't find options with this flag. Zero is the default, and means exclude nothing. |
[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". |
Definition at line 250 of file OptTable.cpp.
References assert(), llvm::StringRef::back(), llvm::ArrayRef< T >::drop_front(), llvm::StringRef::drop_front(), llvm::StringRef::edit_distance(), llvm::StringRef::empty(), P, llvm::cl::Prefix, llvm::StringRef::size(), llvm::StringRef::split(), and llvm::StringRef::startswith().
Referenced by getOptionMetaVar().
|
inline |
Return the total number of option classes.
Definition at line 90 of file OptTable.h.
References getOption(), and llvm::ArrayRef< T >::size().
Referenced by getOption(), OptTable(), and PrintHelp().
const Option OptTable::getOption | ( | OptSpecifier | Opt | ) | const |
Get the given Opt's Option instance, lazily creating it if necessary.
Definition at line 162 of file OptTable.cpp.
References assert(), llvm::opt::OptSpecifier::getID(), and getNumOptions().
Referenced by llvm::opt::Option::getAlias(), llvm::opt::Option::getGroup(), getNumOptions(), getOptionHelpName(), OptTable(), ParseOneArg(), and PrintHelp().
|
inline |
Get the group id for the given option.
Definition at line 109 of file OptTable.h.
Referenced by getOptionHelpGroup().
|
inline |
Get the help text to use to describe this option.
Definition at line 114 of file OptTable.h.
Referenced by getOptionHelpGroup(), and PrintHelp().
|
inline |
Get the kind of the given option.
Definition at line 104 of file OptTable.h.
Referenced by PrintHelp().
|
inline |
Get the meta-variable name to use when describing this options values in the help text.
Definition at line 120 of file OptTable.h.
References addValues(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, findByPrefix(), findNearest(), ParseArgs(), ParseOneArg(), PrintHelp(), suggestValueCompletions(), and llvm::opt::OptTable::Info::Values.
Referenced by getOptionHelpName().
|
inline |
Lookup the name of the given option.
Definition at line 99 of file OptTable.h.
InputArgList OptTable::ParseArgs | ( | ArrayRef< const char *> | Args, |
unsigned & | MissingArgIndex, | ||
unsigned & | MissingArgCount, | ||
unsigned | FlagsToInclude = 0 , |
||
unsigned | FlagsToExclude = 0 |
||
) | 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. |
FlagsToInclude | - Only parse options with any of these flags. Zero is the default which includes all flags. |
FlagsToExclude | - Don't parse options with this flag. Zero is the default and means exclude nothing. |
Definition at line 383 of file OptTable.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Key::Args, llvm::ArrayRef< T >::begin(), and llvm::ArrayRef< T >::end().
Referenced by getOptionMetaVar().
Arg * OptTable::ParseOneArg | ( | const ArgList & | Args, |
unsigned & | Index, | ||
unsigned | FlagsToInclude = 0 , |
||
unsigned | FlagsToExclude = 0 |
||
) | 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] | FlagsToInclude | - Only parse options with any of these flags. Zero is the default which includes all flags. |
[in] | FlagsToExclude | - Don't parse options with this flag. Zero is the default and means exclude nothing. |
Definition at line 324 of file OptTable.cpp.
References Arg, llvm::opt::ArgList::getArgString(), getOption(), and isInput().
Referenced by getOptionMetaVar().
void OptTable::PrintHelp | ( | raw_ostream & | OS, |
const char * | Usage, | ||
const char * | Title, | ||
unsigned | FlagsToInclude, | ||
unsigned | FlagsToExclude, | ||
bool | ShowAllAliases | ||
) | const |
Render the help text for an option table.
OS | - The stream to write the help text to. |
Usage | - USAGE: Usage |
Title | - OVERVIEW: Title |
FlagsToInclude | - If non-zero, only include options with any of these flags set. |
FlagsToExclude | - Exclude options with any of these flags set. |
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 530 of file OptTable.cpp.
References llvm::raw_ostream::flush(), llvm::opt::Option::getAlias(), llvm::opt::Option::getID(), getNumOptions(), getOption(), getOptionHelpGroup(), getOptionHelpName(), getOptionHelpText(), getOptionKind(), llvm::opt::Option::GroupClass, llvm::opt::Option::isValid(), and PrintHelpOptionList().
Referenced by getOptionMetaVar(), and PrintHelp().
void OptTable::PrintHelp | ( | raw_ostream & | OS, |
const char * | Usage, | ||
const char * | Title, | ||
bool | ShowHidden = false , |
||
bool | ShowAllAliases = false |
||
) | const |
Definition at line 524 of file OptTable.cpp.
References llvm::opt::HelpHidden, and PrintHelp().
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 210 of file OptTable.cpp.
References llvm::StringRef::compare(), E, I, llvm::tgtok::In, optionMatches(), llvm::StringRef::split(), and llvm::opt::OptTable::Info::Values.
Referenced by getOptionMetaVar().