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 std::find_if(SubCommands.begin(), SubCommands.end(),
153 [&](
const auto &
C) { return SubCommand == C.Name; });
154 assert(SCIT != SubCommands.end() &&
155 "This helper is only for valid registered subcommands.");
157 unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
158 return std::find(SubCommandIDs.begin(), SubCommandIDs.end(),
159 CurrentSubCommandID) != SubCommandIDs.
end();
184 bool GroupedShortOptions =
false;
185 bool DashDashParsing =
false;
186 const char *EnvVar =
nullptr;
188 unsigned InputOptionID = 0;
189 unsigned UnknownOptionID = 0;
205 unsigned id = Opt.
getID();
207 return OptionInfos[
id - 1];
210 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
211 unsigned &Index)
const;
223 void buildPrefixChars();
235 return PrefixesTable;
249 return getInfo(
id).getName(*StrTable, PrefixesTable);
254 const Info &
I = getInfo(
id);
256 :
I.getPrefix(*StrTable, PrefixesTable, 0);
261 const Info &
I = getInfo(
id);
262 I.appendPrefixes(*StrTable, PrefixesTable, Prefixes);
267 return getInfo(
id).getPrefixedName(*StrTable);
272 return getInfo(
id).Kind;
277 return getInfo(
id).GroupID;
290 auto Info = getInfo(
id);
301 return getInfo(
id).MetaVar;
333 std::vector<std::string> findByPrefix(
StringRef Cur,
335 unsigned int DisableFlags)
const;
355 unsigned MinimumLength = 4,
356 unsigned MaximumDistance = UINT_MAX)
const;
359 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
360 unsigned MinimumLength = 4,
361 unsigned MaximumDistance = UINT_MAX)
const;
366 unsigned MinimumLength,
unsigned MaximumDistance,
367 std::function<
bool(
const Info &)> ExcludeOption)
const;
376 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
394 ParseOneArg(
const ArgList &Args,
unsigned &Index,
397 std::unique_ptr<Arg> ParseOneArg(
const ArgList &Args,
unsigned &Index,
398 unsigned FlagsToInclude,
399 unsigned FlagsToExclude)
const;
403 internalParseOneArg(
const ArgList &Args,
unsigned &Index,
404 std::function<
bool(
const Option &)> ExcludeOption)
const;
424 unsigned &MissingArgCount,
428 unsigned &MissingArgCount,
unsigned FlagsToInclude,
429 unsigned FlagsToExclude = 0)
const;
434 unsigned &MissingArgCount,
435 std::function<
bool(
const Option &)> ExcludeOption)
const;
448 std::function<
void(
StringRef)> ErrorFn)
const;
462 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
463 bool ShowHidden =
false,
bool ShowAllAliases =
false,
467 void printHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
468 unsigned FlagsToInclude,
unsigned FlagsToExclude,
469 bool ShowAllAliases)
const;
472 void internalPrintHelp(
raw_ostream &OS,
const char *Usage,
const char *Title,
475 std::function<
bool(
const Info &)> ExcludeOption,
476 Visibility VisibilityMask)
const;
495 bool IgnoreCase =
false,
498 :
OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase, SubCommands,
499 SubCommandIDsTable) {
500 for (
auto PrefixOffset : PrefixesUnionOffsets)
510#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
511 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
512 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
513 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
516#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
517 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
518 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
519 SUBCOMMANDIDS_OFFSET) \
520 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
521 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
522 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
523 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET)
525#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
526 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
527 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
528 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
529 llvm::opt::OptTable::Info { \
530 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
531 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
532 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES, \
533 SUBCOMMANDIDS_OFFSET \
536#define LLVM_CONSTRUCT_OPT_INFO( \
537 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
538 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
539 SUBCOMMANDIDS_OFFSET) \
540 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
541 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
542 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
543 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.
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.