LLVM 20.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"
17#include <cassert>
18#include <string>
19#include <vector>
20
21namespace llvm {
22
23class raw_ostream;
24template <typename Fn> class function_ref;
25
26namespace opt {
27
28class Arg;
29class ArgList;
30class InputArgList;
31class Option;
32
33/// Helper for overload resolution while transitioning from
34/// FlagsToInclude/FlagsToExclude APIs to VisibilityMask APIs.
36 unsigned Mask = ~0U;
37
38public:
39 explicit Visibility(unsigned Mask) : Mask(Mask) {}
40 Visibility() = default;
41
42 operator unsigned() const { return Mask; }
43};
44
45/// Provide access to the Option info table.
46///
47/// The OptTable class provides a layer of indirection which allows Option
48/// instance to be created lazily. In the common case, only a few options will
49/// be needed at runtime; the OptTable class maintains enough information to
50/// parse command lines without instantiating Options, while letting other
51/// parts of the driver still use Option instances where convenient.
52class OptTable {
53public:
54 /// Entry for a single option instance in the option data table.
55 struct Info {
58 const char *HelpText;
59 // Help text for specific visibilities. A list of pairs, where each pair
60 // is a list of visibilities and a specific help string for those
61 // visibilities. If no help text is found in this list for the visibility of
62 // the program, HelpText is used instead. This cannot use std::vector
63 // because OptTable is used in constexpr contexts. Increase the array sizes
64 // here if you need more entries and adjust the constants in
65 // OptionParserEmitter::EmitHelpTextsForVariants.
66 std::array<std::pair<std::array<unsigned int, 2 /*MaxVisibilityPerHelp*/>,
67 const char *>,
68 1 /*MaxVisibilityHelp*/>
70 const char *MetaVar;
71 unsigned ID;
72 unsigned char Kind;
73 unsigned char Param;
74 unsigned int Flags;
75 unsigned int Visibility;
76 unsigned short GroupID;
77 unsigned short AliasID;
78 const char *AliasArgs;
79 const char *Values;
80
81 bool hasNoPrefix() const { return PrefixesOffset == 0; }
82
83 unsigned getNumPrefixes(ArrayRef<unsigned> PrefixesTable) const {
84 return PrefixesTable[PrefixesOffset];
85 }
86
88 getPrefixOffsets(ArrayRef<unsigned> PrefixesTable) const {
90 : PrefixesTable.slice(PrefixesOffset + 1,
91 getNumPrefixes(PrefixesTable));
92 }
93
94 void appendPrefixes(const char *StrTable, ArrayRef<unsigned> PrefixesTable,
95 SmallVectorImpl<StringRef> &Prefixes) const {
96 for (unsigned PrefixOffset : getPrefixOffsets(PrefixesTable))
97 Prefixes.push_back(&StrTable[PrefixOffset]);
98 }
99
100 StringRef getPrefix(const char *StrTable, ArrayRef<unsigned> PrefixesTable,
101 unsigned PrefixIndex) const {
102 return &StrTable[getPrefixOffsets(PrefixesTable)[PrefixIndex]];
103 }
104
105 StringRef getPrefixedName(const char *StrTable) const {
106 return &StrTable[PrefixedNameOffset];
107 }
108
109 StringRef getName(const char *StrTable,
110 ArrayRef<unsigned> PrefixesTable) const {
111 unsigned PrefixLength =
112 hasNoPrefix() ? 0 : getPrefix(StrTable, PrefixesTable, 0).size();
113 return getPrefixedName(StrTable).drop_front(PrefixLength);
114 }
115 };
116
117private:
118 // A unified string table for these options. Individual strings are stored as
119 // null terminated C-strings at offsets within this table.
120 const char *StrTable;
121
122 // A table of different sets of prefixes. Each set starts with the number of
123 // prefixes in that set followed by that many offsets into the string table
124 // for each of the prefix strings. This is essentially a Pascal-string style
125 // encoding.
126 ArrayRef<unsigned> PrefixesTable;
127
128 /// The option information table.
129 ArrayRef<Info> OptionInfos;
130
131 bool IgnoreCase;
132 bool GroupedShortOptions = false;
133 bool DashDashParsing = false;
134 const char *EnvVar = nullptr;
135
136 unsigned InputOptionID = 0;
137 unsigned UnknownOptionID = 0;
138
139protected:
140 /// The index of the first option which can be parsed (i.e., is not a
141 /// special option like 'input' or 'unknown', and is not an option group).
143
144 /// The union of all option prefixes. If an argument does not begin with
145 /// one of these, it is an input.
147
148 /// The union of the first element of all option prefixes.
150
151private:
152 const Info &getInfo(OptSpecifier Opt) const {
153 unsigned id = Opt.getID();
154 assert(id > 0 && id - 1 < getNumOptions() && "Invalid Option ID.");
155 return OptionInfos[id - 1];
156 }
157
158 std::unique_ptr<Arg> parseOneArgGrouped(InputArgList &Args,
159 unsigned &Index) const;
160
161protected:
162 /// Initialize OptTable using Tablegen'ed OptionInfos. Child class must
163 /// manually call \c buildPrefixChars once they are fully constructed.
164 OptTable(const char *StrTable, ArrayRef<unsigned> PrefixesTable,
165 ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
166
167 /// Build (or rebuild) the PrefixChars member.
168 void buildPrefixChars();
169
170public:
171 virtual ~OptTable();
172
173 /// Return the string table used for option names.
174 const char *getStrTable() const { return StrTable; }
175
176 /// Return the prefixes table used for option names.
177 ArrayRef<unsigned> getPrefixesTable() const { return PrefixesTable; }
178
179 /// Return the total number of option classes.
180 unsigned getNumOptions() const { return OptionInfos.size(); }
181
182 /// Get the given Opt's Option instance, lazily creating it
183 /// if necessary.
184 ///
185 /// \return The option, or null for the INVALID option id.
186 const Option getOption(OptSpecifier Opt) const;
187
188 /// Lookup the name of the given option.
190 return getInfo(id).getName(StrTable, PrefixesTable);
191 }
192
193 /// Lookup the prefix of the given option.
195 const Info &I = getInfo(id);
196 return I.hasNoPrefix() ? StringRef()
197 : I.getPrefix(StrTable, PrefixesTable, 0);
198 }
199
201 SmallVectorImpl<StringRef> &Prefixes) const {
202 const Info &I = getInfo(id);
203 I.appendPrefixes(StrTable, PrefixesTable, Prefixes);
204 }
205
206 /// Lookup the prefixed name of the given option.
208 return getInfo(id).getPrefixedName(StrTable);
209 }
210
211 /// Get the kind of the given option.
212 unsigned getOptionKind(OptSpecifier id) const {
213 return getInfo(id).Kind;
214 }
215
216 /// Get the group id for the given option.
217 unsigned getOptionGroupID(OptSpecifier id) const {
218 return getInfo(id).GroupID;
219 }
220
221 /// Get the help text to use to describe this option.
222 const char *getOptionHelpText(OptSpecifier id) const {
223 return getOptionHelpText(id, Visibility(0));
224 }
225
226 // Get the help text to use to describe this option.
227 // If it has visibility specific help text and that visibility is in the
228 // visibility mask, use that text instead of the generic text.
230 Visibility VisibilityMask) const {
231 auto Info = getInfo(id);
232 for (auto [Visibilities, Text] : Info.HelpTextsForVariants)
233 for (auto Visibility : Visibilities)
234 if (VisibilityMask & Visibility)
235 return Text;
236 return Info.HelpText;
237 }
238
239 /// Get the meta-variable name to use when describing
240 /// this options values in the help text.
241 const char *getOptionMetaVar(OptSpecifier id) const {
242 return getInfo(id).MetaVar;
243 }
244
245 /// Specify the environment variable where initial options should be read.
246 void setInitialOptionsFromEnvironment(const char *E) { EnvVar = E; }
247
248 /// Support grouped short options. e.g. -ab represents -a -b.
249 void setGroupedShortOptions(bool Value) { GroupedShortOptions = Value; }
250
251 /// Set whether "--" stops option parsing and treats all subsequent arguments
252 /// as positional. E.g. -- -a -b gives two positional inputs.
253 void setDashDashParsing(bool Value) { DashDashParsing = Value; }
254
255 /// Find possible value for given flags. This is used for shell
256 /// autocompletion.
257 ///
258 /// \param [in] Option - Key flag like "-stdlib=" when "-stdlib=l"
259 /// was passed to clang.
260 ///
261 /// \param [in] Arg - Value which we want to autocomplete like "l"
262 /// when "-stdlib=l" was passed to clang.
263 ///
264 /// \return The vector of possible values.
265 std::vector<std::string> suggestValueCompletions(StringRef Option,
266 StringRef Arg) const;
267
268 /// Find flags from OptTable which starts with Cur.
269 ///
270 /// \param [in] Cur - String prefix that all returned flags need
271 // to start with.
272 ///
273 /// \return The vector of flags which start with Cur.
274 std::vector<std::string> findByPrefix(StringRef Cur,
275 Visibility VisibilityMask,
276 unsigned int DisableFlags) const;
277
278 /// Find the OptTable option that most closely matches the given string.
279 ///
280 /// \param [in] Option - A string, such as "-stdlibs=l", that represents user
281 /// input of an option that may not exist in the OptTable. Note that the
282 /// string includes prefix dashes "-" as well as values "=l".
283 /// \param [out] NearestString - The nearest option string found in the
284 /// OptTable.
285 /// \param [in] VisibilityMask - Only include options with any of these
286 /// visibility flags set.
287 /// \param [in] MinimumLength - Don't find options shorter than this length.
288 /// For example, a minimum length of 3 prevents "-x" from being considered
289 /// near to "-S".
290 /// \param [in] MaximumDistance - Don't find options whose distance is greater
291 /// than this value.
292 ///
293 /// \return The edit distance of the nearest string found.
294 unsigned findNearest(StringRef Option, std::string &NearestString,
295 Visibility VisibilityMask = Visibility(),
296 unsigned MinimumLength = 4,
297 unsigned MaximumDistance = UINT_MAX) const;
298
299 unsigned findNearest(StringRef Option, std::string &NearestString,
300 unsigned FlagsToInclude, unsigned FlagsToExclude = 0,
301 unsigned MinimumLength = 4,
302 unsigned MaximumDistance = UINT_MAX) const;
303
304private:
305 unsigned
306 internalFindNearest(StringRef Option, std::string &NearestString,
307 unsigned MinimumLength, unsigned MaximumDistance,
308 std::function<bool(const Info &)> ExcludeOption) const;
309
310public:
311 bool findExact(StringRef Option, std::string &ExactString,
312 Visibility VisibilityMask = Visibility()) const {
313 return findNearest(Option, ExactString, VisibilityMask, 4, 0) == 0;
314 }
315
316 bool findExact(StringRef Option, std::string &ExactString,
317 unsigned FlagsToInclude, unsigned FlagsToExclude = 0) const {
318 return findNearest(Option, ExactString, FlagsToInclude, FlagsToExclude, 4,
319 0) == 0;
320 }
321
322 /// Parse a single argument; returning the new argument and
323 /// updating Index.
324 ///
325 /// \param [in,out] Index - The current parsing position in the argument
326 /// string list; on return this will be the index of the next argument
327 /// string to parse.
328 /// \param [in] VisibilityMask - Only include options with any of these
329 /// visibility flags set.
330 ///
331 /// \return The parsed argument, or 0 if the argument is missing values
332 /// (in which case Index still points at the conceptual next argument string
333 /// to parse).
334 std::unique_ptr<Arg>
335 ParseOneArg(const ArgList &Args, unsigned &Index,
336 Visibility VisibilityMask = Visibility()) const;
337
338 std::unique_ptr<Arg> ParseOneArg(const ArgList &Args, unsigned &Index,
339 unsigned FlagsToInclude,
340 unsigned FlagsToExclude) const;
341
342private:
343 std::unique_ptr<Arg>
344 internalParseOneArg(const ArgList &Args, unsigned &Index,
345 std::function<bool(const Option &)> ExcludeOption) const;
346
347public:
348 /// Parse an list of arguments into an InputArgList.
349 ///
350 /// The resulting InputArgList will reference the strings in [\p ArgBegin,
351 /// \p ArgEnd), and their lifetime should extend past that of the returned
352 /// InputArgList.
353 ///
354 /// The only error that can occur in this routine is if an argument is
355 /// missing values; in this case \p MissingArgCount will be non-zero.
356 ///
357 /// \param MissingArgIndex - On error, the index of the option which could
358 /// not be parsed.
359 /// \param MissingArgCount - On error, the number of missing options.
360 /// \param VisibilityMask - Only include options with any of these
361 /// visibility flags set.
362 /// \return An InputArgList; on error this will contain all the options
363 /// which could be parsed.
364 InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
365 unsigned &MissingArgCount,
366 Visibility VisibilityMask = Visibility()) const;
367
368 InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
369 unsigned &MissingArgCount, unsigned FlagsToInclude,
370 unsigned FlagsToExclude = 0) const;
371
372private:
374 internalParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
375 unsigned &MissingArgCount,
376 std::function<bool(const Option &)> ExcludeOption) const;
377
378public:
379 /// A convenience helper which handles optional initial options populated from
380 /// an environment variable, expands response files recursively and parses
381 /// options.
382 ///
383 /// \param ErrorFn - Called on a formatted error message for missing arguments
384 /// or unknown options.
385 /// \return An InputArgList; on error this will contain all the options which
386 /// could be parsed.
387 InputArgList parseArgs(int Argc, char *const *Argv, OptSpecifier Unknown,
388 StringSaver &Saver,
389 std::function<void(StringRef)> ErrorFn) const;
390
391 /// Render the help text for an option table.
392 ///
393 /// \param OS - The stream to write the help text to.
394 /// \param Usage - USAGE: Usage
395 /// \param Title - OVERVIEW: Title
396 /// \param VisibilityMask - Only in Visibility VisibilityMask,clude options with any of these
397 /// visibility flags set.
398 /// \param ShowHidden - If true, display options marked as HelpHidden
399 /// \param ShowAllAliases - If true, display all options including aliases
400 /// that don't have help texts. By default, we display
401 /// only options that are not hidden and have help
402 /// texts.
403 void printHelp(raw_ostream &OS, const char *Usage, const char *Title,
404 bool ShowHidden = false, bool ShowAllAliases = false,
405 Visibility VisibilityMask = Visibility()) const;
406
407 void printHelp(raw_ostream &OS, const char *Usage, const char *Title,
408 unsigned FlagsToInclude, unsigned FlagsToExclude,
409 bool ShowAllAliases) const;
410
411private:
412 void internalPrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
413 bool ShowHidden, bool ShowAllAliases,
414 std::function<bool(const Info &)> ExcludeOption,
415 Visibility VisibilityMask) const;
416};
417
418/// Specialization of OptTable
419class GenericOptTable : public OptTable {
420protected:
421 GenericOptTable(const char *StrTable, ArrayRef<unsigned> PrefixesTable,
422 ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
423};
424
426protected:
427 PrecomputedOptTable(const char *StrTable, ArrayRef<unsigned> PrefixesTable,
428 ArrayRef<Info> OptionInfos,
429 ArrayRef<unsigned> PrefixesUnionOffsets,
430 bool IgnoreCase = false)
431 : OptTable(StrTable, PrefixesTable, OptionInfos, IgnoreCase) {
432 for (unsigned PrefixOffset : PrefixesUnionOffsets)
433 PrefixesUnion.push_back(&StrTable[PrefixOffset]);
435 }
436};
437
438} // end namespace opt
439
440} // end namespace llvm
441
442#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX( \
443 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
444 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
445 METAVAR, VALUES) \
446 ID_PREFIX##ID
447
448#define LLVM_MAKE_OPT_ID(PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, \
449 GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, PARAM, \
450 HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
451 LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, \
452 ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
453 VISIBILITY, PARAM, HELPTEXT, \
454 HELPTEXTSFORVARIANTS, METAVAR, VALUE)
455
456#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
457 ID_PREFIX, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
458 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
459 METAVAR, VALUES) \
460 llvm::opt::OptTable::Info { \
461 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, HELPTEXT, HELPTEXTSFORVARIANTS, \
462 METAVAR, ID_PREFIX##ID, llvm::opt::Option::KIND##Class, PARAM, FLAGS, \
463 VISIBILITY, ID_PREFIX##GROUP, ID_PREFIX##ALIAS, ALIASARGS, VALUES \
464 }
465
466#define LLVM_CONSTRUCT_OPT_INFO( \
467 PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, ALIASARGS, \
468 FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, VALUES) \
469 LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
470 OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, ID, KIND, GROUP, ALIAS, \
471 ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, \
472 METAVAR, VALUES)
473
474#endif // LLVM_OPTION_OPTTABLE_H
arm prera ldst opt
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
uint32_t Index
#define I(x, y, z)
Definition: MD5.cpp:58
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:168
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:198
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...
Definition: SmallVector.h:573
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:609
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:150
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:21
LLVM Value Representation.
Definition: Value.h:74
ArgList - Ordered collection of driver arguments.
Definition: ArgList.h:116
A concrete instance of a particular driver option.
Definition: Arg.h:34
Specialization of OptTable.
Definition: OptTable.h:419
OptSpecifier - Wrapper class for abstracting references to option IDs.
Definition: OptSpecifier.h:18
unsigned getID() const
Definition: OptSpecifier.h:29
Provide access to the Option info table.
Definition: OptTable.h:52
void buildPrefixChars()
Build (or rebuild) the PrefixChars member.
Definition: OptTable.cpp:123
StringRef getOptionName(OptSpecifier id) const
Lookup the name of the given option.
Definition: OptTable.h:189
const char * getOptionHelpText(OptSpecifier id, Visibility VisibilityMask) const
Definition: OptTable.h:229
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,...
Definition: OptTable.cpp:580
unsigned getOptionKind(OptSpecifier id) const
Get the kind of the given option.
Definition: OptTable.h:212
unsigned FirstSearchableIndex
The index of the first option which can be parsed (i.e., is not a special option like 'input' or 'unk...
Definition: OptTable.h:142
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.
Definition: OptTable.cpp:714
const char * getOptionMetaVar(OptSpecifier id) const
Get the meta-variable name to use when describing this options values in the help text.
Definition: OptTable.h:241
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.
Definition: OptTable.cpp:414
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:233
SmallVector< StringRef > PrefixesUnion
The union of all option prefixes.
Definition: OptTable.h:146
const Option getOption(OptSpecifier Opt) const
Get the given Opt's Option instance, lazily creating it if necessary.
Definition: OptTable.cpp:136
const char * getOptionHelpText(OptSpecifier id) const
Get the help text to use to describe this option.
Definition: OptTable.h:222
StringRef getOptionPrefix(OptSpecifier id) const
Lookup the prefix of the given option.
Definition: OptTable.h:194
bool findExact(StringRef Option, std::string &ExactString, unsigned FlagsToInclude, unsigned FlagsToExclude=0) const
Definition: OptTable.h:316
void setInitialOptionsFromEnvironment(const char *E)
Specify the environment variable where initial options should be read.
Definition: OptTable.h:246
const char * getStrTable() const
Return the string table used for option names.
Definition: OptTable.h:174
void setDashDashParsing(bool Value)
Set whether "--" stops option parsing and treats all subsequent arguments as positional.
Definition: OptTable.h:253
ArrayRef< unsigned > getPrefixesTable() const
Return the prefixes table used for option names.
Definition: OptTable.h:177
unsigned getOptionGroupID(OptSpecifier id) const
Get the group id for the given option.
Definition: OptTable.h:217
std::vector< std::string > suggestValueCompletions(StringRef Option, StringRef Arg) const
Find possible value for given flags.
Definition: OptTable.cpp:188
InputArgList ParseArgs(ArrayRef< const char * > Args, unsigned &MissingArgIndex, unsigned &MissingArgCount, Visibility VisibilityMask=Visibility()) const
Parse an list of arguments into an InputArgList.
Definition: OptTable.cpp:498
StringRef getOptionPrefixedName(OptSpecifier id) const
Lookup the prefixed name of the given option.
Definition: OptTable.h:207
SmallString< 8 > PrefixChars
The union of the first element of all option prefixes.
Definition: OptTable.h:149
void appendOptionPrefixes(OptSpecifier id, SmallVectorImpl< StringRef > &Prefixes) const
Definition: OptTable.h:200
unsigned getNumOptions() const
Return the total number of option classes.
Definition: OptTable.h:180
bool findExact(StringRef Option, std::string &ExactString, Visibility VisibilityMask=Visibility()) const
Definition: OptTable.h:311
std::vector< std::string > findByPrefix(StringRef Cur, Visibility VisibilityMask, unsigned int DisableFlags) const
Find flags from OptTable which starts with Cur.
Definition: OptTable.cpp:208
void setGroupedShortOptions(bool Value)
Support grouped short options. e.g. -ab represents -a -b.
Definition: OptTable.h:249
Option - Abstract representation for a single form of driver argument.
Definition: Option.h:54
PrecomputedOptTable(const char *StrTable, ArrayRef< unsigned > PrefixesTable, ArrayRef< Info > OptionInfos, ArrayRef< unsigned > PrefixesUnionOffsets, bool IgnoreCase=false)
Definition: OptTable.h:427
Helper for overload resolution while transitioning from FlagsToInclude/FlagsToExclude APIs to Visibil...
Definition: OptTable.h:35
Visibility(unsigned Mask)
Definition: OptTable.h:39
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Entry for a single option instance in the option data table.
Definition: OptTable.h:55
bool hasNoPrefix() const
Definition: OptTable.h:81
StringRef getName(const char *StrTable, ArrayRef< unsigned > PrefixesTable) const
Definition: OptTable.h:109
unsigned char Param
Definition: OptTable.h:73
unsigned int Visibility
Definition: OptTable.h:75
const char * Values
Definition: OptTable.h:79
unsigned short AliasID
Definition: OptTable.h:77
void appendPrefixes(const char *StrTable, ArrayRef< unsigned > PrefixesTable, SmallVectorImpl< StringRef > &Prefixes) const
Definition: OptTable.h:94
unsigned getNumPrefixes(ArrayRef< unsigned > PrefixesTable) const
Definition: OptTable.h:83
unsigned PrefixedNameOffset
Definition: OptTable.h:57
unsigned short GroupID
Definition: OptTable.h:76
unsigned int Flags
Definition: OptTable.h:74
const char * HelpText
Definition: OptTable.h:58
const char * MetaVar
Definition: OptTable.h:70
ArrayRef< unsigned > getPrefixOffsets(ArrayRef< unsigned > PrefixesTable) const
Definition: OptTable.h:88
StringRef getPrefix(const char *StrTable, ArrayRef< unsigned > PrefixesTable, unsigned PrefixIndex) const
Definition: OptTable.h:100
unsigned char Kind
Definition: OptTable.h:72
StringRef getPrefixedName(const char *StrTable) const
Definition: OptTable.h:105
std::array< std::pair< std::array< unsigned int, 2 >, const char * >, 1 > HelpTextsForVariants
Definition: OptTable.h:69
const char * AliasArgs
Definition: OptTable.h:78