LLVM 24.0.0git
OptTable.h
Go to the documentation of this file.
1//===- OptTable.h - Option Table --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_OPTION_OPTTABLE_H
10#define LLVM_OPTION_OPTTABLE_H
11
12#include "llvm/ADT/ArrayRef.h"
14#include "llvm/ADT/StringRef.h"
19#include <cassert>
20#include <string>
21#include <vector>
22
23namespace llvm {
24
25class raw_ostream;
26template <typename Fn> class function_ref;
27
28namespace opt {
29
30class Arg;
31class ArgList;
32class InputArgList;
33class Option;
34
35/// Helper for overload resolution while transitioning from
36/// FlagsToInclude/FlagsToExclude APIs to VisibilityMask APIs.
38 unsigned Mask = ~0U;
39
40public:
41 explicit Visibility(unsigned Mask) : Mask(Mask) {}
42 Visibility() = default;
43
44 operator unsigned() const { return Mask; }
45};
46
47/// Provide access to the Option info table.
48///
49/// The OptTable class provides a layer of indirection which allows Option
50/// instance to be created lazily. In the common case, only a few options will
51/// be needed at runtime; the OptTable class maintains enough information to
52/// parse command lines without instantiating Options, while letting other
53/// parts of the driver still use Option instances where convenient.
55public:
56 /// Represents a subcommand and its options in the option table.
57 struct SubCommand {
58 const char *Name;
59 const char *HelpText;
60 const char *Usage;
61 };
62
63 /// Values of options declared with TableGen `ValuesCode`: only the generated
64 /// code knows them, so they cannot go in the string table. The generated
65 /// table supplies getOptionValuesCode() for this.
67
68 /// Help text that replaces Info::HelpTextOffset when the visibility mask
69 /// being printed intersects Visibility. An option's variants form a run
70 /// ended by a zero Visibility.
75
76 /// Fields few options set. Row 0 is all zero and serves the options that set
77 /// none.
78 struct InfoExtra {
81 /// The possible values as a comma separated list, empty for an option whose
82 /// values only getOptionValuesCode() knows.
84 // Offset into OptTable's HelpTextVariantsTable; 0 for none.
85 unsigned short HelpTextVariantsOffset;
86 // Offset into OptTable's SubCommandIDsTable.
87 unsigned short SubCommandIDsOffset;
88 };
89
90 /// Entry for a single option instance in the option data table. An option's
91 /// ID is its 1-based position in the table.
92 struct Info {
94 /// Offset 0 means the .td supplied no HelpText. A HelpText<""> maps to a
95 /// distinct empty string, marking the option deliberately undocumented.
97 unsigned Flags;
98 unsigned short Visibility;
99 // Offset into OptTable's PrefixesTable.
100 unsigned short PrefixesOffset;
101 unsigned short GroupID;
102 unsigned short AliasID;
103 // Offset into OptTable's InfoExtrasTable.
104 unsigned short ExtraOffset;
105 unsigned char Kind;
106 unsigned char Param;
107
108 bool hasNoPrefix() const { return PrefixesOffset == 0; }
109
110 unsigned getNumPrefixes(ArrayRef<StringTable::Offset> PrefixesTable) const {
111 // We embed the number of prefixes in the value of the first offset.
112 return PrefixesTable[PrefixesOffset].value();
113 }
114
118 : PrefixesTable.slice(PrefixesOffset + 1,
119 getNumPrefixes(PrefixesTable));
120 }
121
122 bool hasHelpText() const { return HelpTextOffset.value() != 0; }
123
124 void appendPrefixes(const StringTable &StrTable,
125 ArrayRef<StringTable::Offset> PrefixesTable,
126 SmallVectorImpl<StringRef> &Prefixes) const {
127 for (auto PrefixOffset : getPrefixOffsets(PrefixesTable))
128 Prefixes.push_back(StrTable[PrefixOffset]);
129 }
130
132 ArrayRef<StringTable::Offset> PrefixesTable,
133 unsigned PrefixIndex) const {
134 return StrTable[getPrefixOffsets(PrefixesTable)[PrefixIndex]];
135 }
136
137 StringRef getPrefixedName(const StringTable &StrTable) const {
138 return StrTable[PrefixedNameOffset];
139 }
140
142 ArrayRef<StringTable::Offset> PrefixesTable) const {
143 unsigned PrefixLength =
144 hasNoPrefix() ? 0 : getPrefix(StrTable, PrefixesTable, 0).size();
145 return getPrefixedName(StrTable).drop_front(PrefixLength);
146 }
147 };
148
149 /// The tables TableGen emits for an option set under OPTTABLE_CODE.
159
160public:
161 bool isValidForSubCommand(const Info *CandidateInfo,
162 StringRef SubCommand) const {
163 assert(!SubCommand.empty() &&
164 "This helper is only for valid registered subcommands.");
165 auto SCIT = llvm::find_if(
166 SubCommands, [&](const auto &C) { return SubCommand == C.Name; });
167 assert(SCIT != SubCommands.end() &&
168 "This helper is only for valid registered subcommands.");
169 auto SubCommandIDs = getSubCommandIDs(*CandidateInfo);
170 unsigned CurrentSubCommandID = SCIT - &SubCommands[0];
171 return llvm::is_contained(SubCommandIDs, CurrentSubCommandID);
172 }
173
174private:
175 // A unified string table for these options. Individual strings are stored as
176 // null terminated C-strings at offsets within this table.
177 StringTable StrTable;
178
179 // A table of different sets of prefixes. Each set starts with the number of
180 // prefixes in that set followed by that many offsets into the string table
181 // for each of the prefix strings. This is essentially a Pascal-string style
182 // encoding.
183 ArrayRef<StringTable::Offset> PrefixesTable;
184
185 /// The option information table.
186 ArrayRef<Info> OptionInfos;
187
188 ArrayRef<InfoExtra> InfoExtrasTable;
189
190 bool IgnoreCase;
191
192 /// The subcommand information table.
193 ArrayRef<SubCommand> SubCommands;
194
195 /// The subcommand IDs table.
196 ArrayRef<unsigned> SubCommandIDsTable;
197
198 ArrayRef<HelpTextVariant> HelpTextVariantsTable;
199
200 ValuesCodeFnTy ValuesCodeFn = nullptr;
201
202 bool GroupedShortOptions = false;
203 bool DashDashParsing = false;
204 const char *EnvVar = nullptr;
205
206 unsigned InputOptionID = 0;
207 unsigned UnknownOptionID = 0;
208
209 /// The index of the first option which can be parsed (i.e., is not a
210 /// special option like 'input' or 'unknown', and is not an option group).
211 unsigned FirstSearchableIndex = 0;
212
213 /// The union of all option prefixes. If an argument does not begin with
214 /// one of these, it is an input.
215 SmallVector<StringRef> PrefixesUnion;
216
217 /// The union of the first element of all option prefixes.
218 SmallString<8> PrefixChars;
219
220 const Info &getInfo(OptSpecifier Opt) const {
221 unsigned id = Opt.getID();
222 assert(id > 0 && id - 1 < getNumOptions() && "Invalid Option ID.");
223 return OptionInfos[id - 1];
224 }
225
226 const InfoExtra &getExtra(const Info &I) const {
227 return InfoExtrasTable[I.ExtraOffset];
228 }
229
230 StringTable::Offset getHelpTextOffset(const Info &I,
231 Visibility VisibilityMask) const {
232 for (const HelpTextVariant *V =
233 &HelpTextVariantsTable[getExtra(I).HelpTextVariantsOffset];
234 V->Visibility; ++V)
235 if (VisibilityMask & V->Visibility)
236 return V->HelpTextOffset;
237 return I.HelpTextOffset;
238 }
239
240 StringRef getOptionValues(const Info &I) const {
241 StringRef Values = StrTable[getExtra(I).ValuesOffset];
242 if (Values.empty() && ValuesCodeFn)
243 Values = ValuesCodeFn(getOptionID(I));
244 return Values;
245 }
246
247 ArrayRef<unsigned> getSubCommandIDs(const Info &I) const {
248 // A set starts with its size.
249 unsigned Offset = getExtra(I).SubCommandIDsOffset;
250 return SubCommandIDsTable.slice(Offset + 1, SubCommandIDsTable[Offset]);
251 }
252
253 std::unique_ptr<Arg> parseOneArgGrouped(InputArgList &Args,
254 unsigned &Index) const;
255
256protected:
257 OptTable(const Tables &Tables, bool IgnoreCase = false);
258
259 void setValuesCodeFn(ValuesCodeFnTy Fn) { ValuesCodeFn = Fn; }
260
261public:
262 virtual ~OptTable();
263
264 /// Return the string table used for option names.
265 const StringTable &getStrTable() const { return StrTable; }
266
267 ArrayRef<SubCommand> getSubCommands() const { return SubCommands; }
268
269 /// Return the prefixes table used for option names.
271 return PrefixesTable;
272 }
273
274 /// Return the total number of option classes.
275 unsigned getNumOptions() const { return OptionInfos.size(); }
276
277 unsigned getOptionID(const Info &I) const {
278 return &I - OptionInfos.data() + 1;
279 }
280
281 /// Get the given Opt's Option instance, lazily creating it
282 /// if necessary.
283 ///
284 /// \return The option, or null for the INVALID option id.
285 const Option getOption(OptSpecifier Opt) const;
286
287 /// Lookup the name of the given option.
289 return getInfo(id).getName(StrTable, PrefixesTable);
290 }
291
292 /// Lookup the prefix of the given option.
294 const Info &I = getInfo(id);
295 return I.hasNoPrefix() ? StringRef()
296 : I.getPrefix(StrTable, PrefixesTable, 0);
297 }
298
300 SmallVectorImpl<StringRef> &Prefixes) const {
301 const Info &I = getInfo(id);
302 I.appendPrefixes(StrTable, PrefixesTable, Prefixes);
303 }
304
305 /// Lookup the prefixed name of the given option.
307 return getInfo(id).getPrefixedName(StrTable);
308 }
309
310 /// Get the kind of the given option.
311 unsigned getOptionKind(OptSpecifier id) const {
312 return getInfo(id).Kind;
313 }
314
315 /// Get the group id for the given option.
316 unsigned getOptionGroupID(OptSpecifier id) const {
317 return getInfo(id).GroupID;
318 }
319
320 /// Get the help text to use to describe this option.
324
325 // Get the help text to use to describe this option.
326 // If it has visibility specific help text and that visibility is in the
327 // visibility mask, use that text instead of the generic text.
329 Visibility VisibilityMask) const {
330 return StrTable[getHelpTextOffset(getInfo(id), VisibilityMask)];
331 }
332
333 /// Get the meta-variable name to use when describing
334 /// this options values in the help text.
336 return StrTable[getExtra(getInfo(id)).MetaVarOffset];
337 }
338
339 /// Get the alias arguments as a \0 separated list, e.g. "foo\0bar\0".
340 const char *getOptionAliasArgs(OptSpecifier id) const {
341 return StrTable.getCString(getExtra(getInfo(id)).AliasArgsOffset);
342 }
343
344 /// Specify the environment variable where initial options should be read.
345 void setInitialOptionsFromEnvironment(const char *E) { EnvVar = E; }
346
347 /// Support grouped short options. e.g. -ab represents -a -b.
348 void setGroupedShortOptions(bool Value) { GroupedShortOptions = Value; }
349
350 /// Set whether "--" stops option parsing and treats all subsequent arguments
351 /// as positional. E.g. -- -a -b gives two positional inputs.
352 void setDashDashParsing(bool Value) { DashDashParsing = Value; }
353
354 /// Find possible value for given flags. This is used for shell
355 /// autocompletion.
356 ///
357 /// \param [in] Option - Key flag like "-stdlib=" when "-stdlib=l"
358 /// was passed to clang.
359 ///
360 /// \param [in] Arg - Value which we want to autocomplete like "l"
361 /// when "-stdlib=l" was passed to clang.
362 ///
363 /// \return The vector of possible values.
364 std::vector<std::string> suggestValueCompletions(StringRef Option,
365 StringRef Arg) const;
366
367 /// Find flags from OptTable which starts with Cur.
368 ///
369 /// \param [in] Cur - String prefix that all returned flags need
370 // to start with.
371 ///
372 /// \return The vector of flags which start with Cur.
373 std::vector<std::string> findByPrefix(StringRef Cur,
374 Visibility VisibilityMask,
375 unsigned int DisableFlags) const;
376
377 /// Find the OptTable option that most closely matches the given string.
378 ///
379 /// \param [in] Option - A string, such as "-stdlibs=l", that represents user
380 /// input of an option that may not exist in the OptTable. Note that the
381 /// string includes prefix dashes "-" as well as values "=l".
382 /// \param [out] NearestString - The nearest option string found in the
383 /// OptTable.
384 /// \param [in] VisibilityMask - Only include options with any of these
385 /// visibility flags set.
386 /// \param [in] MinimumLength - Don't find options shorter than this length.
387 /// For example, a minimum length of 3 prevents "-x" from being considered
388 /// near to "-S".
389 /// \param [in] MaximumDistance - Don't find options whose distance is greater
390 /// than this value.
391 ///
392 /// \return The edit distance of the nearest string found.
393 unsigned findNearest(StringRef Option, std::string &NearestString,
394 Visibility VisibilityMask = Visibility(),
395 unsigned MinimumLength = 4,
396 unsigned MaximumDistance = UINT_MAX) const;
397
398 unsigned findNearest(StringRef Option, std::string &NearestString,
399 unsigned FlagsToInclude, unsigned FlagsToExclude = 0,
400 unsigned MinimumLength = 4,
401 unsigned MaximumDistance = UINT_MAX) const;
402
403private:
404 unsigned
405 internalFindNearest(StringRef Option, std::string &NearestString,
406 unsigned MinimumLength, unsigned MaximumDistance,
407 std::function<bool(const Info &)> ExcludeOption) const;
408
409public:
410 bool findExact(StringRef Option, std::string &ExactString,
411 Visibility VisibilityMask = Visibility()) const {
412 return findNearest(Option, ExactString, VisibilityMask, 4, 0) == 0;
413 }
414
415 bool findExact(StringRef Option, std::string &ExactString,
416 unsigned FlagsToInclude, unsigned FlagsToExclude = 0) const {
417 return findNearest(Option, ExactString, FlagsToInclude, FlagsToExclude, 4,
418 0) == 0;
419 }
420
421 /// Parse a single argument; returning the new argument and
422 /// updating Index.
423 ///
424 /// \param [in,out] Index - The current parsing position in the argument
425 /// string list; on return this will be the index of the next argument
426 /// string to parse.
427 /// \param [in] VisibilityMask - Only include options with any of these
428 /// visibility flags set.
429 ///
430 /// \return The parsed argument, or 0 if the argument is missing values
431 /// (in which case Index still points at the conceptual next argument string
432 /// to parse).
433 std::unique_ptr<Arg>
434 ParseOneArg(const ArgList &Args, unsigned &Index,
435 Visibility VisibilityMask = Visibility()) const;
436
437 std::unique_ptr<Arg> ParseOneArg(const ArgList &Args, unsigned &Index,
438 unsigned FlagsToInclude,
439 unsigned FlagsToExclude) const;
440
441private:
442 std::unique_ptr<Arg>
443 internalParseOneArg(const ArgList &Args, unsigned &Index,
444 std::function<bool(const Option &)> ExcludeOption) const;
445
446public:
447 /// Parse an list of arguments into an InputArgList.
448 ///
449 /// The resulting InputArgList will reference the strings in [\p ArgBegin,
450 /// \p ArgEnd), and their lifetime should extend past that of the returned
451 /// InputArgList.
452 ///
453 /// The only error that can occur in this routine is if an argument is
454 /// missing values; in this case \p MissingArgCount will be non-zero.
455 ///
456 /// \param MissingArgIndex - On error, the index of the option which could
457 /// not be parsed.
458 /// \param MissingArgCount - On error, the number of missing options.
459 /// \param VisibilityMask - Only include options with any of these
460 /// visibility flags set.
461 /// \return An InputArgList; on error this will contain all the options
462 /// which could be parsed.
463 InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
464 unsigned &MissingArgCount,
465 Visibility VisibilityMask = Visibility()) const;
466
467 InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
468 unsigned &MissingArgCount, unsigned FlagsToInclude,
469 unsigned FlagsToExclude = 0) const;
470
471private:
473 internalParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
474 unsigned &MissingArgCount,
475 std::function<bool(const Option &)> ExcludeOption) const;
476
477public:
478 /// A convenience helper which handles optional initial options populated from
479 /// an environment variable, expands response files recursively and parses
480 /// options.
481 ///
482 /// \param ErrorFn - Called on a formatted error message for missing arguments
483 /// or unknown options.
484 /// \return An InputArgList; on error this will contain all the options which
485 /// could be parsed.
486 InputArgList parseArgs(int Argc, char *const *Argv, OptSpecifier Unknown,
487 StringSaver &Saver,
488 std::function<void(StringRef)> ErrorFn) const;
489
490 /// Render the help text for an option table.
491 ///
492 /// \param OS - The stream to write the help text to.
493 /// \param Usage - USAGE: Usage
494 /// \param Title - OVERVIEW: Title
495 /// \param VisibilityMask - Only in Visibility VisibilityMask,clude options with any of these
496 /// visibility flags set.
497 /// \param ShowHidden - If true, display options marked as HelpHidden
498 /// \param ShowAllAliases - If true, display all options including aliases
499 /// that don't have help texts. By default, we display
500 /// only options that are not hidden and have help
501 /// texts.
502 void printHelp(raw_ostream &OS, const char *Usage, const char *Title,
503 bool ShowHidden = false, bool ShowAllAliases = false,
504 Visibility VisibilityMask = Visibility(),
505 StringRef SubCommand = {}) const;
506
507 void printHelp(raw_ostream &OS, const char *Usage, const char *Title,
508 unsigned FlagsToInclude, unsigned FlagsToExclude,
509 bool ShowAllAliases) const;
510
511private:
512 void internalPrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
513 StringRef SubCommand, bool ShowHidden,
514 bool ShowAllAliases,
515 std::function<bool(const Info &)> ExcludeOption,
516 Visibility VisibilityMask) const;
517};
518
519} // end namespace opt
520
521} // end namespace llvm
522
523#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
524 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
525 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
526 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET) \
527 ID_PREFIX##ID
528
529#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
530 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
531 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES, \
532 SUBCOMMANDIDS_OFFSET) \
533 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
534 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
535 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
536 METAVAR, VALUES, SUBCOMMANDIDS_OFFSET)
537
538#endif // LLVM_OPTION_OPTTABLE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
#define I(x, y, z)
Definition MD5.cpp:57
static Expected< size_t > parseArgs(StringRef Section, mcdxbc::SourceInfo::ProgramArgs &Args)
This file defines the SmallString class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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.
Definition ArrayRef.h:185
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition StringSaver.h:22
A table of densely packed, null-terminated strings indexed by offset.
Definition StringTable.h:34
LLVM Value Representation.
Definition Value.h:75
An efficient, type-erasing, non-owning reference to a callable.
ArgList - Ordered collection of driver arguments.
Definition ArgList.h:118
A concrete instance of a particular driver option.
Definition Arg.h:35
OptSpecifier - Wrapper class for abstracting references to option IDs.
unsigned getID() const
bool isValidForSubCommand(const Info *CandidateInfo, StringRef SubCommand) const
Definition OptTable.h:161
StringRef getOptionName(OptSpecifier id) const
Lookup the name of the given option.
Definition OptTable.h:288
unsigned getOptionKind(OptSpecifier id) const
Get the kind of the given option.
Definition OptTable.h:311
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.
Definition OptTable.cpp:234
StringRef getOptionPrefix(OptSpecifier id) const
Lookup the prefix of the given option.
Definition OptTable.h:293
bool findExact(StringRef Option, std::string &ExactString, unsigned FlagsToInclude, unsigned FlagsToExclude=0) const
Definition OptTable.h:415
void setInitialOptionsFromEnvironment(const char *E)
Specify the environment variable where initial options should be read.
Definition OptTable.h:345
void setDashDashParsing(bool Value)
Set whether "--" stops option parsing and treats all subsequent arguments as positional.
Definition OptTable.h:352
StringRef getOptionHelpText(OptSpecifier id, Visibility VisibilityMask) const
Definition OptTable.h:328
StringRef(*)(unsigned) ValuesCodeFnTy
Values of options declared with TableGen ValuesCode: only the generated code knows them,...
Definition OptTable.h:66
const char * getOptionAliasArgs(OptSpecifier id) const
Get the alias arguments as a \0 separated list, e.g. "foo\0bar\0".
Definition OptTable.h:340
void setValuesCodeFn(ValuesCodeFnTy Fn)
Definition OptTable.h:259
unsigned getOptionGroupID(OptSpecifier id) const
Get the group id for the given option.
Definition OptTable.h:316
StringRef getOptionMetaVar(OptSpecifier id) const
Get the meta-variable name to use when describing this options values in the help text.
Definition OptTable.h:335
OptTable(const Tables &Tables, bool IgnoreCase=false)
Definition OptTable.cpp:76
StringRef getOptionPrefixedName(OptSpecifier id) const
Lookup the prefixed name of the given option.
Definition OptTable.h:306
ArrayRef< StringTable::Offset > getPrefixesTable() const
Return the prefixes table used for option names.
Definition OptTable.h:270
void appendOptionPrefixes(OptSpecifier id, SmallVectorImpl< StringRef > &Prefixes) const
Definition OptTable.h:299
unsigned getOptionID(const Info &I) const
Definition OptTable.h:277
unsigned getNumOptions() const
Return the total number of option classes.
Definition OptTable.h:275
bool findExact(StringRef Option, std::string &ExactString, Visibility VisibilityMask=Visibility()) const
Definition OptTable.h:410
StringRef getOptionHelpText(OptSpecifier id) const
Get the help text to use to describe this option.
Definition OptTable.h:321
ArrayRef< SubCommand > getSubCommands() const
Definition OptTable.h:267
const StringTable & getStrTable() const
Return the string table used for option names.
Definition OptTable.h:265
void setGroupedShortOptions(bool Value)
Support grouped short options. e.g. -ab represents -a -b.
Definition OptTable.h:348
Option - Abstract representation for a single form of driver argument.
Definition Option.h:55
Helper for overload resolution while transitioning from FlagsToInclude/FlagsToExclude APIs to Visibil...
Definition OptTable.h:37
Visibility(unsigned Mask)
Definition OptTable.h:41
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
@ Unknown
Not known to have no common set bits.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1963
Help text that replaces Info::HelpTextOffset when the visibility mask being printed intersects Visibi...
Definition OptTable.h:71
StringTable::Offset HelpTextOffset
Definition OptTable.h:73
Fields few options set.
Definition OptTable.h:78
unsigned short HelpTextVariantsOffset
Definition OptTable.h:85
unsigned short SubCommandIDsOffset
Definition OptTable.h:87
StringTable::Offset AliasArgsOffset
Definition OptTable.h:80
StringTable::Offset MetaVarOffset
Definition OptTable.h:79
StringTable::Offset ValuesOffset
The possible values as a comma separated list, empty for an option whose values only getOptionValuesC...
Definition OptTable.h:83
Entry for a single option instance in the option data table.
Definition OptTable.h:92
unsigned short ExtraOffset
Definition OptTable.h:104
void appendPrefixes(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, SmallVectorImpl< StringRef > &Prefixes) const
Definition OptTable.h:124
bool hasNoPrefix() const
Definition OptTable.h:108
StringTable::Offset PrefixedNameOffset
Definition OptTable.h:93
unsigned getNumPrefixes(ArrayRef< StringTable::Offset > PrefixesTable) const
Definition OptTable.h:110
bool hasHelpText() const
Definition OptTable.h:122
StringRef getPrefixedName(const StringTable &StrTable) const
Definition OptTable.h:137
ArrayRef< StringTable::Offset > getPrefixOffsets(ArrayRef< StringTable::Offset > PrefixesTable) const
Definition OptTable.h:116
unsigned short AliasID
Definition OptTable.h:102
StringTable::Offset HelpTextOffset
Offset 0 means the .td supplied no HelpText.
Definition OptTable.h:96
StringRef getPrefix(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable, unsigned PrefixIndex) const
Definition OptTable.h:131
unsigned short PrefixesOffset
Definition OptTable.h:100
StringRef getName(const StringTable &StrTable, ArrayRef< StringTable::Offset > PrefixesTable) const
Definition OptTable.h:141
unsigned short Visibility
Definition OptTable.h:98
unsigned short GroupID
Definition OptTable.h:101
Represents a subcommand and its options in the option table.
Definition OptTable.h:57
The tables TableGen emits for an option set under OPTTABLE_CODE.
Definition OptTable.h:150
ArrayRef< unsigned > SubCommandIDs
Definition OptTable.h:157
ArrayRef< InfoExtra > InfoExtras
Definition OptTable.h:154
ArrayRef< SubCommand > SubCommands
Definition OptTable.h:156
ArrayRef< HelpTextVariant > HelpTextVariants
Definition OptTable.h:155
ArrayRef< StringTable::Offset > PrefixesTable
Definition OptTable.h:152
ArrayRef< Info > Infos
Definition OptTable.h:153