9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
24template <
typename Fn>
class function_ref;
82 bool GroupedShortOptions =
false;
83 bool DashDashParsing =
false;
84 const char *EnvVar =
nullptr;
86 unsigned InputOptionID = 0;
87 unsigned UnknownOptionID = 0;
103 unsigned id = Opt.
getID();
105 return OptionInfos[
id - 1];
108 std::unique_ptr<Arg> parseOneArgGrouped(
InputArgList &Args,
109 unsigned &
Index)
const;
138 return getInfo(
id).
Kind;
188 unsigned int DisableFlags)
const;
208 unsigned MinimumLength = 4,
209 unsigned MaximumDistance = UINT_MAX)
const;
212 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0,
213 unsigned MinimumLength = 4,
214 unsigned MaximumDistance = UINT_MAX)
const;
219 unsigned MinimumLength,
unsigned MaximumDistance,
220 std::function<
bool(
const Info &)> ExcludeOption)
const;
229 unsigned FlagsToInclude,
unsigned FlagsToExclude = 0)
const {
251 unsigned FlagsToInclude,
252 unsigned FlagsToExclude)
const;
256 internalParseOneArg(
const ArgList &Args,
unsigned &
Index,
257 std::function<
bool(
const Option &)> ExcludeOption)
const;
277 unsigned &MissingArgCount,
281 unsigned &MissingArgCount,
unsigned FlagsToInclude,
282 unsigned FlagsToExclude = 0)
const;
287 unsigned &MissingArgCount,
288 std::function<
bool(
const Option &)> ExcludeOption)
const;
301 std::function<
void(
StringRef)> ErrorFn)
const;
316 bool ShowHidden =
false,
bool ShowAllAliases =
false,
320 unsigned FlagsToInclude,
unsigned FlagsToExclude,
321 bool ShowAllAliases)
const;
324 void internalPrintHelp(
raw_ostream &
OS,
const char *Usage,
const char *Title,
325 bool ShowHidden,
bool ShowAllAliases,
326 std::function<
bool(
const Info &)> ExcludeOption)
const;
336 return PrefixesUnionBuffer;
346 bool IgnoreCase =
false)
347 :
OptTable(OptionInfos, IgnoreCase), PrefixesUnion(PrefixesTable) {
351 return PrefixesUnion;
359#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
360 ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
361 FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
364#define LLVM_MAKE_OPT_ID(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, \
365 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, \
367 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIX, PREFIXED_NAME, ID, KIND, \
368 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, \
369 PARAM, HELPTEXT, METAVAR, VALUE)
371#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
372 ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
373 FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
374 llvm::opt::OptTable::Info { \
375 PREFIX, PREFIXED_NAME, HELPTEXT, METAVAR, ID_PREFIX##ID, \
376 llvm::opt::Option::KIND##Class, PARAM, FLAGS, VISIBILITY, \
377 ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES \
380#define LLVM_CONSTRUCT_OPT_INFO(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, \
381 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, \
383 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
384 OPT_, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
385 VISIBILITY, PARAM, HELPTEXT, 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.
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.