9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
25template <
typename Fn>
class function_ref;
67 std::array<std::pair<std::array<
unsigned int, 2 >,
100 Prefixes.
push_back(StrTable[PrefixOffset]);
105 unsigned PrefixIndex)
const {
115 unsigned PrefixLength =
136 bool GroupedShortOptions =
false;
137 bool DashDashParsing =
false;
138 const char *EnvVar =
nullptr;
140 unsigned InputOptionID = 0;
141 unsigned UnknownOptionID = 0;
157 unsigned id = Opt.
getID();
159 return OptionInfos[
id - 1];
162 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
163 unsigned &
Index)
const;
183 return PrefixesTable;
197 return getInfo(
id).
getName(*StrTable, PrefixesTable);
202 const Info &
I = getInfo(
id);
204 :
I.getPrefix(*StrTable, PrefixesTable, 0);
209 const Info &
I = getInfo(
id);
210 I.appendPrefixes(*StrTable, PrefixesTable, Prefixes);
220 return getInfo(
id).
Kind;
238 auto Info = getInfo(
id);
283 unsigned int DisableFlags)
const;
303 unsigned MinimumLength = 4,
304 unsigned MaximumDistance = UINT_MAX)
const;
307 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
308 unsigned MinimumLength = 4,
309 unsigned MaximumDistance = UINT_MAX)
const;
314 unsigned MinimumLength,
unsigned MaximumDistance,
315 std::function<
bool(
const Info &)> ExcludeOption)
const;
324 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
346 unsigned FlagsToInclude,
347 unsigned FlagsToExclude)
const;
351 internalParseOneArg(
const ArgList &Args,
unsigned &
Index,
352 std::function<
bool(
const Option &)> ExcludeOption)
const;
372 unsigned &MissingArgCount,
376 unsigned &MissingArgCount,
unsigned FlagsToInclude,
377 unsigned FlagsToExclude = 0)
const;
382 unsigned &MissingArgCount,
383 std::function<
bool(
const Option &)> ExcludeOption)
const;
396 std::function<
void(
StringRef)> ErrorFn)
const;
411 bool ShowHidden =
false,
bool ShowAllAliases =
false,
415 unsigned FlagsToInclude,
unsigned FlagsToExclude,
416 bool ShowAllAliases)
const;
419 void internalPrintHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
420 bool ShowHidden,
bool ShowAllAliases,
421 std::function<
bool(
const Info &)> ExcludeOption,
439 bool IgnoreCase =
false)
440 :
OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase) {
441 for (
auto PrefixOffset : PrefixesUnionOffsets)
451#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
452 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
453 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
457#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
458 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
459 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
460 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, \
461 ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
462 VISIBILITY, PARAM, HELPTEXT, \
463 HELPTEXTSFORVARIANTS, METAVAR, VALUES)
465#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
466 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
467 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
469 llvm::opt::OptTable::Info { \
470 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
471 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
472 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES \
475#define LLVM_CONSTRUCT_OPT_INFO( \
476 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
477 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
478 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
479 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
480 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.
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
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.
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.
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.
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
std::vector< std::string > findByPrefix(StringRef Cur, Visibility VisibilityMask, unsigned int DisableFlags) const
Find flags from OptTable which starts with Cur.
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