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