9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
24template <
typename Fn>
class function_ref;
68 std::array<std::pair<std::array<
unsigned int, 2 >,
93 bool GroupedShortOptions =
false;
94 bool DashDashParsing =
false;
95 const char *EnvVar =
nullptr;
97 unsigned InputOptionID = 0;
98 unsigned UnknownOptionID = 0;
114 unsigned id = Opt.
getID();
116 return OptionInfos[
id - 1];
119 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
120 unsigned &
Index)
const;
149 return getInfo(
id).
Kind;
167 auto Info = getInfo(
id);
212 unsigned int DisableFlags)
const;
232 unsigned MinimumLength = 4,
233 unsigned MaximumDistance = UINT_MAX)
const;
236 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
237 unsigned MinimumLength = 4,
238 unsigned MaximumDistance = UINT_MAX)
const;
243 unsigned MinimumLength,
unsigned MaximumDistance,
244 std::function<
bool(
const Info &)> ExcludeOption)
const;
253 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
275 unsigned FlagsToInclude,
276 unsigned FlagsToExclude)
const;
280 internalParseOneArg(
const ArgList &Args,
unsigned &
Index,
281 std::function<
bool(
const Option &)> ExcludeOption)
const;
301 unsigned &MissingArgCount,
305 unsigned &MissingArgCount,
unsigned FlagsToInclude,
306 unsigned FlagsToExclude = 0)
const;
311 unsigned &MissingArgCount,
312 std::function<
bool(
const Option &)> ExcludeOption)
const;
325 std::function<
void(
StringRef)> ErrorFn)
const;
340 bool ShowHidden =
false,
bool ShowAllAliases =
false,
344 unsigned FlagsToInclude,
unsigned FlagsToExclude,
345 bool ShowAllAliases)
const;
348 void internalPrintHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
349 bool ShowHidden,
bool ShowAllAliases,
350 std::function<
bool(
const Info &)> ExcludeOption,
361 return PrefixesUnionBuffer;
371 bool IgnoreCase =
false)
372 :
OptTable(OptionInfos, IgnoreCase), PrefixesUnion(PrefixesTable) {
376 return PrefixesUnion;
384#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
385 ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
386 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
389#define LLVM_MAKE_OPT_ID(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, \
390 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, \
391 HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
392 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
393 OPT_, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
394 VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUE)
396#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
397 ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
398 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
399 llvm::opt::OptTable::Info { \
400 PREFIX, PREFIXED_NAME, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, \
401 ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
402 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES \
405#define LLVM_CONSTRUCT_OPT_INFO(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, \
406 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, \
407 HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
408 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
409 OPT_, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
410 VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES)
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.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
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.
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.
ArrayRef< StringLiteral > getPrefixesUnion() const final
The union of all option prefixes.
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.
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.
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.
SmallString< 8 > PrefixChars
The union of the first element of all option prefixes.
virtual ArrayRef< StringLiteral > getPrefixesUnion() const =0
The union of all option prefixes.
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(ArrayRef< Info > OptionInfos, ArrayRef< StringLiteral > PrefixesTable, bool IgnoreCase=false)
ArrayRef< StringLiteral > getPrefixesUnion() const final
The union of all option prefixes.
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.
StringLiteral PrefixedName
StringRef getName() const
ArrayRef< StringLiteral > Prefixes
A null terminated array of prefix strings to apply to name while matching.
std::array< std::pair< std::array< unsigned int, 2 >, const char * >, 1 > HelpTextsForVariants