9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
75 std::array<std::pair<std::array<
unsigned int, 2 >,
125 Prefixes.
push_back(StrTable[PrefixOffset]);
130 unsigned PrefixIndex)
const {
140 unsigned PrefixLength =
150 "This helper is only for valid registered subcommands.");
152 SubCommands, [&](
const auto &
C) {
return SubCommand ==
C.Name; });
153 assert(SCIT != SubCommands.end() &&
154 "This helper is only for valid registered subcommands.");
156 unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
182 bool GroupedShortOptions =
false;
183 bool DashDashParsing =
false;
184 const char *EnvVar =
nullptr;
186 unsigned InputOptionID = 0;
187 unsigned UnknownOptionID = 0;
203 unsigned id = Opt.
getID();
205 return OptionInfos[
id - 1];
208 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
209 unsigned &Index)
const;
221 void buildPrefixChars();
233 return PrefixesTable;
247 return getInfo(
id).getName(*StrTable, PrefixesTable);
252 const Info &
I = getInfo(
id);
254 :
I.getPrefix(*StrTable, PrefixesTable, 0);
259 const Info &
I = getInfo(
id);
260 I.appendPrefixes(*StrTable, PrefixesTable, Prefixes);
265 return getInfo(
id).getPrefixedName(*StrTable);
270 return getInfo(
id).Kind;
275 return getInfo(
id).GroupID;
288 auto Info = getInfo(
id);
299 return getInfo(
id).MetaVar;
331 std::vector<std::string> findByPrefix(
StringRef Cur,
333 unsigned int DisableFlags)
const;
353 unsigned MinimumLength = 4,
354 unsigned MaximumDistance = UINT_MAX)
const;
357 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
358 unsigned MinimumLength = 4,
359 unsigned MaximumDistance = UINT_MAX)
const;
364 unsigned MinimumLength,
unsigned MaximumDistance,
365 std::function<
bool(
const Info &)> ExcludeOption)
const;
374 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
392 ParseOneArg(
const ArgList &Args,
unsigned &Index,
395 std::unique_ptr<Arg> ParseOneArg(
const ArgList &Args,
unsigned &Index,
396 unsigned FlagsToInclude,
397 unsigned FlagsToExclude)
const;
401 internalParseOneArg(
const ArgList &Args,
unsigned &Index,
402 std::function<
bool(
const Option &)> ExcludeOption)
const;
422 unsigned &MissingArgCount,
426 unsigned &MissingArgCount,
unsigned FlagsToInclude,
427 unsigned FlagsToExclude = 0)
const;
432 unsigned &MissingArgCount,
433 std::function<
bool(
const Option &)> ExcludeOption)
const;
446 std::function<
void(
StringRef)> ErrorFn)
const;
460 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
461 bool ShowHidden =
false,
bool ShowAllAliases =
false,
465 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
466 unsigned FlagsToInclude,
unsigned FlagsToExclude,
467 bool ShowAllAliases)
const;
470 void internalPrintHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
473 std::function<
bool(
const Info &)> ExcludeOption,
474 Visibility VisibilityMask)
const;
493 bool IgnoreCase =
false,
496 :
OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase, SubCommands,
497 SubCommandIDsTable) {
498 for (
auto PrefixOffset : PrefixesUnionOffsets)
508#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
509 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
510 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
511 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
514#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
515 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
516 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
517 SUBCOMMANDIDS_OFFSET) \
518 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
519 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
520 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
521 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET)
523#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
524 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
525 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
526 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
527 llvm::opt::OptTable::Info { \
528 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
529 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
530 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES, \
531 SUBCOMMANDIDS_OFFSET \
534#define LLVM_CONSTRUCT_OPT_INFO( \
535 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
536 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
537 SUBCOMMANDIDS_OFFSET) \
538 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
539 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
540 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
541 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
A table of densely packed, null-terminated strings indexed by offset.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
ArgList - Ordered collection of driver arguments.
A concrete instance of a particular driver option.
LLVM_ABI GenericOptTable(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, ArrayRef< Info > OptionInfos, bool IgnoreCase=false, ArrayRef< SubCommand > SubCommands={}, ArrayRef< unsigned > SubCommandIDsTable={})
OptSpecifier - Wrapper class for abstracting references to option IDs.
Provide access to the Option info table.
void buildPrefixChars()
Build (or rebuild) the PrefixChars member.
bool isValidForSubCommand(const Info *CandidateInfo, StringRef SubCommand) const
StringRef getOptionName(OptSpecifier id) const
Lookup the name of the given option.
const char * getOptionHelpText(OptSpecifier id, Visibility VisibilityMask) const
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...
const char * getOptionMetaVar(OptSpecifier id) const
Get the meta-variable name to use when describing this options values in the help text.
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 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.
OptTable(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, ArrayRef< Info > OptionInfos, bool IgnoreCase=false, ArrayRef< SubCommand > SubCommands={}, ArrayRef< unsigned > SubCommandIDsTable={})
Initialize OptTable using Tablegen'ed OptionInfos.
void setDashDashParsing(bool Value)
Set whether "--" stops option parsing and treats all subsequent arguments as positional.
unsigned getOptionGroupID(OptSpecifier id) const
Get the group id for the given option.
StringRef getOptionPrefixedName(OptSpecifier id) const
Lookup the prefixed name of the given option.
ArrayRef< StringTable::Offset > getPrefixesTable() const
Return the prefixes table used for option names.
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
ArrayRef< SubCommand > getSubCommands() const
const StringTable & getStrTable() const
Return the string table used for option names.
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 StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, ArrayRef< Info > OptionInfos, ArrayRef< StringTable::Offset > PrefixesUnionOffsets, bool IgnoreCase=false, ArrayRef< SubCommand > SubCommands={}, ArrayRef< unsigned > SubCommandIDsTable={})
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.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Entry for a single option instance in the option data table.
void appendPrefixes(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, SmallVectorImpl< StringRef > &Prefixes) const
StringTable::Offset PrefixedNameOffset
unsigned getNumPrefixes(ArrayRef< StringTable::Offset > PrefixesTable) const
bool hasSubCommands() const
StringRef getPrefixedName(const StringTable &StrTable) const
ArrayRef< StringTable::Offset > getPrefixOffsets(ArrayRef< StringTable::Offset > PrefixesTable) const
StringRef getPrefix(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, unsigned PrefixIndex) const
StringRef getName(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable) const
unsigned SubCommandIDsOffset
ArrayRef< unsigned > getSubCommandIDs(ArrayRef< unsigned > SubCommandIDsTable) const
unsigned getNumSubCommandIDs(ArrayRef< unsigned > SubCommandIDsTable) const
std::array< std::pair< std::array< unsigned int, 2 >, const char * >, 1 > HelpTextsForVariants
Represents a subcommand and its options in the option table.