9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
24template <
typename Fn>
class function_ref;
66 std::array<std::pair<std::array<
unsigned int, 2 >,
97 Prefixes.
push_back(&StrTable[PrefixOffset]);
101 unsigned PrefixIndex)
const {
111 unsigned PrefixLength =
120 const char *StrTable;
132 bool GroupedShortOptions =
false;
133 bool DashDashParsing =
false;
134 const char *EnvVar =
nullptr;
136 unsigned InputOptionID = 0;
137 unsigned UnknownOptionID = 0;
153 unsigned id = Opt.
getID();
155 return OptionInfos[
id - 1];
158 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
159 unsigned &
Index)
const;
190 return getInfo(
id).
getName(StrTable, PrefixesTable);
195 const Info &
I = getInfo(
id);
197 :
I.getPrefix(StrTable, PrefixesTable, 0);
202 const Info &
I = getInfo(
id);
203 I.appendPrefixes(StrTable, PrefixesTable, Prefixes);
213 return getInfo(
id).
Kind;
231 auto Info = getInfo(
id);
276 unsigned int DisableFlags)
const;
296 unsigned MinimumLength = 4,
297 unsigned MaximumDistance = UINT_MAX)
const;
300 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
301 unsigned MinimumLength = 4,
302 unsigned MaximumDistance = UINT_MAX)
const;
307 unsigned MinimumLength,
unsigned MaximumDistance,
308 std::function<
bool(
const Info &)> ExcludeOption)
const;
317 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
339 unsigned FlagsToInclude,
340 unsigned FlagsToExclude)
const;
344 internalParseOneArg(
const ArgList &Args,
unsigned &
Index,
345 std::function<
bool(
const Option &)> ExcludeOption)
const;
365 unsigned &MissingArgCount,
369 unsigned &MissingArgCount,
unsigned FlagsToInclude,
370 unsigned FlagsToExclude = 0)
const;
375 unsigned &MissingArgCount,
376 std::function<
bool(
const Option &)> ExcludeOption)
const;
389 std::function<
void(
StringRef)> ErrorFn)
const;
404 bool ShowHidden =
false,
bool ShowAllAliases =
false,
408 unsigned FlagsToInclude,
unsigned FlagsToExclude,
409 bool ShowAllAliases)
const;
412 void internalPrintHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
413 bool ShowHidden,
bool ShowAllAliases,
414 std::function<
bool(
const Info &)> ExcludeOption,
430 bool IgnoreCase =
false)
431 :
OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase) {
432 for (
unsigned PrefixOffset : PrefixesUnionOffsets)
442#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
443 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
444 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
448#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
449 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
450 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
451 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, \
452 ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
453 VISIBILITY, PARAM, HELPTEXT, \
454 HELPTEXTSFORVARIANTS, METAVAR, VALUE)
456#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
457 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
458 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
460 llvm::opt::OptTable::Info { \
461 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
462 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
463 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES \
466#define LLVM_CONSTRUCT_OPT_INFO( \
467 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
468 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
469 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
470 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
471 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
size - Get the string size.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
LLVM Value Representation.
ArgList - Ordered collection of driver arguments.
A concrete instance of a particular driver option.
Specialization of OptTable.
OptSpecifier - Wrapper class for abstracting references to option IDs.
Provide access to the Option info table.
void buildPrefixChars()
Build (or rebuild) the PrefixChars member.
StringRef getOptionName(OptSpecifier id) const
Lookup the name of the given option.
const char * getOptionHelpText(OptSpecifier id, Visibility VisibilityMask) 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,...
unsigned getOptionKind(OptSpecifier id) const
Get the kind of the given option.
unsigned FirstSearchableIndex
The index of the first option which can be parsed (i.e., is not a special option like 'input' or 'unk...
void printHelp(raw_ostream &OS, const char *Usage, const char *Title, bool ShowHidden=false, bool ShowAllAliases=false, Visibility VisibilityMask=Visibility()) const
Render the help text for an option table.
const char * getOptionMetaVar(OptSpecifier id) const
Get the meta-variable name to use when describing this options values in the help text.
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.
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.
SmallVector< StringRef > PrefixesUnion
The union of all option prefixes.
const Option getOption(OptSpecifier Opt) const
Get the given Opt's Option instance, lazily creating it if necessary.
const char * getOptionHelpText(OptSpecifier id) const
Get the help text to use to describe this option.
StringRef getOptionPrefix(OptSpecifier id) const
Lookup the prefix of the given option.
bool findExact(StringRef Option, std::string &ExactString, unsigned FlagsToInclude, unsigned FlagsToExclude=0) const
void setInitialOptionsFromEnvironment(const char *E)
Specify the environment variable where initial options should be read.
const char * getStrTable() const
Return the string table used for option names.
void setDashDashParsing(bool Value)
Set whether "--" stops option parsing and treats all subsequent arguments as positional.
ArrayRef< unsigned > getPrefixesTable() const
Return the prefixes table used for option names.
unsigned getOptionGroupID(OptSpecifier id) const
Get the group id for the given option.
std::vector< std::string > suggestValueCompletions(StringRef Option, StringRef Arg) const
Find possible value for given flags.
InputArgList ParseArgs(ArrayRef< const char * > Args, unsigned &MissingArgIndex, unsigned &MissingArgCount, Visibility VisibilityMask=Visibility()) const
Parse an list of arguments into an InputArgList.
StringRef getOptionPrefixedName(OptSpecifier id) const
Lookup the prefixed name of the given option.
SmallString< 8 > PrefixChars
The union of the first element of all option prefixes.
void appendOptionPrefixes(OptSpecifier id, SmallVectorImpl< StringRef > &Prefixes) const
unsigned getNumOptions() const
Return the total number of option classes.
bool findExact(StringRef Option, std::string &ExactString, Visibility VisibilityMask=Visibility()) const
std::vector< std::string > findByPrefix(StringRef Cur, Visibility VisibilityMask, unsigned int DisableFlags) const
Find flags from OptTable which starts with Cur.
void setGroupedShortOptions(bool Value)
Support grouped short options. e.g. -ab represents -a -b.
Option - Abstract representation for a single form of driver argument.
PrecomputedOptTable(const char *StrTable, ArrayRef< unsigned > PrefixesTable, ArrayRef< Info > OptionInfos, ArrayRef< unsigned > PrefixesUnionOffsets, bool IgnoreCase=false)
Helper for overload resolution while transitioning from FlagsToInclude/FlagsToExclude APIs to Visibil...
Visibility(unsigned Mask)
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
Entry for a single option instance in the option data table.
StringRef getName(const char *StrTable, ArrayRef< unsigned > PrefixesTable) const
void appendPrefixes(const char *StrTable, ArrayRef< unsigned > PrefixesTable, SmallVectorImpl< StringRef > &Prefixes) const
unsigned getNumPrefixes(ArrayRef< unsigned > PrefixesTable) const
unsigned PrefixedNameOffset
ArrayRef< unsigned > getPrefixOffsets(ArrayRef< unsigned > PrefixesTable) const
StringRef getPrefix(const char *StrTable, ArrayRef< unsigned > PrefixesTable, unsigned PrefixIndex) const
StringRef getPrefixedName(const char *StrTable) const
std::array< std::pair< std::array< unsigned int, 2 >, const char * >, 1 > HelpTextsForVariants