9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
26template <
typename Fn>
class function_ref;
68 std::array<std::pair<std::array<
unsigned int, 2 >,
87 return PrefixesTable[PrefixesOffset].value();
93 : PrefixesTable.
slice(PrefixesOffset + 1,
94 getNumPrefixes(PrefixesTable));
100 for (
auto PrefixOffset : getPrefixOffsets(PrefixesTable))
101 Prefixes.
push_back(StrTable[PrefixOffset]);
106 unsigned PrefixIndex)
const {
107 return StrTable[getPrefixOffsets(PrefixesTable)[PrefixIndex]];
111 return StrTable[PrefixedNameOffset];
116 unsigned PrefixLength =
117 hasNoPrefix() ? 0 : getPrefix(StrTable, PrefixesTable, 0).
size();
118 return getPrefixedName(StrTable).drop_front(PrefixLength);
137 bool GroupedShortOptions =
false;
138 bool DashDashParsing =
false;
139 const char *EnvVar =
nullptr;
141 unsigned InputOptionID = 0;
142 unsigned UnknownOptionID = 0;
147 unsigned FirstSearchableIndex = 0;
158 unsigned id = Opt.
getID();
159 assert(
id > 0 &&
id - 1 < getNumOptions() &&
"Invalid Option ID.");
160 return OptionInfos[
id - 1];
163 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
164 unsigned &
Index)
const;
174 void buildPrefixChars();
184 return PrefixesTable;
198 return getInfo(
id).getName(*StrTable, PrefixesTable);
203 const Info &
I = getInfo(
id);
205 :
I.getPrefix(*StrTable, PrefixesTable, 0);
210 const Info &
I = getInfo(
id);
211 I.appendPrefixes(*StrTable, PrefixesTable, Prefixes);
216 return getInfo(
id).getPrefixedName(*StrTable);
221 return getInfo(
id).Kind;
226 return getInfo(
id).GroupID;
239 auto Info = getInfo(
id);
250 return getInfo(
id).MetaVar;
282 std::vector<std::string> findByPrefix(
StringRef Cur,
284 unsigned int DisableFlags)
const;
304 unsigned MinimumLength = 4,
305 unsigned MaximumDistance = UINT_MAX)
const;
308 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
309 unsigned MinimumLength = 4,
310 unsigned MaximumDistance = UINT_MAX)
const;
315 unsigned MinimumLength,
unsigned MaximumDistance,
316 std::function<
bool(
const Info &)> ExcludeOption)
const;
321 return findNearest(
Option, ExactString, VisibilityMask, 4, 0) == 0;
325 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
326 return findNearest(
Option, ExactString, FlagsToInclude, FlagsToExclude, 4,
346 std::unique_ptr<Arg> ParseOneArg(
const ArgList &Args,
unsigned &
Index,
347 unsigned FlagsToInclude,
348 unsigned FlagsToExclude)
const;
352 internalParseOneArg(
const ArgList &Args,
unsigned &
Index,
353 std::function<
bool(
const Option &)> ExcludeOption)
const;
373 unsigned &MissingArgCount,
377 unsigned &MissingArgCount,
unsigned FlagsToInclude,
378 unsigned FlagsToExclude = 0)
const;
383 unsigned &MissingArgCount,
384 std::function<
bool(
const Option &)> ExcludeOption)
const;
397 std::function<
void(
StringRef)> ErrorFn)
const;
411 void printHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
412 bool ShowHidden =
false,
bool ShowAllAliases =
false,
415 void printHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
416 unsigned FlagsToInclude,
unsigned FlagsToExclude,
417 bool ShowAllAliases)
const;
420 void internalPrintHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
421 bool ShowHidden,
bool ShowAllAliases,
422 std::function<
bool(
const Info &)> ExcludeOption,
440 bool IgnoreCase =
false)
441 :
OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase) {
442 for (
auto PrefixOffset : PrefixesUnionOffsets)
452#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
453 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
454 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
458#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
459 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
460 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
461 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, \
462 ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
463 VISIBILITY, PARAM, HELPTEXT, \
464 HELPTEXTSFORVARIANTS, METAVAR, VALUES)
466#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
467 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
468 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
470 llvm::opt::OptTable::Info { \
471 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
472 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
473 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES \
476#define LLVM_CONSTRUCT_OPT_INFO( \
477 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
478 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
479 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
480 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
481 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
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),...
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.
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.
A table of densely packed, null-terminated strings indexed by offset.
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
unsigned getOptionKind(OptSpecifier id) const
Get the kind of the given option.
const char * getOptionMetaVar(OptSpecifier id) const
Get the meta-variable name to use when describing this options values in the help text.
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.
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
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)
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.
void appendPrefixes(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, SmallVectorImpl< StringRef > &Prefixes) const
StringTable::Offset PrefixedNameOffset
unsigned getNumPrefixes(ArrayRef< StringTable::Offset > PrefixesTable) 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
std::array< std::pair< std::array< unsigned int, 2 >, const char * >, 1 > HelpTextsForVariants