12#include "llvm/Config/llvm-config.h"
30 "Multi-level aliases are not supported.");
36 "Cannot provide alias args to a flag option.");
43#define P(N) case N: O << #N; break
66 << (
I ==
N - 1 ?
"\"" :
"\", ");
70 O <<
" Name:\"" <<
getName() <<
'"';
75 Group.
print(O,
false);
81 Alias.
print(O,
false);
92#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
112std::unique_ptr<Arg> Option::acceptInternal(
const ArgList &Args,
114 unsigned &Index)
const {
115 const size_t SpellingSize = Spelling.
size();
116 const size_t ArgStringSize =
StringRef(Args.getArgString(Index)).
size();
119 if (SpellingSize != ArgStringSize)
121 return std::make_unique<Arg>(*
this, Spelling, Index++);
124 const char *
Value = Args.getArgString(Index) + SpellingSize;
125 return std::make_unique<Arg>(*
this, Spelling, Index++,
Value);
129 const char *Str = Args.getArgString(Index) + SpellingSize;
130 auto A = std::make_unique<Arg>(*
this, Spelling, Index++);
133 const char *Prev = Str;
137 if (!c || c ==
',') {
139 char *
Value =
new char[Str - Prev + 1];
140 memcpy(
Value, Prev, Str - Prev);
141 Value[Str - Prev] =
'\0';
142 A->getValues().push_back(
Value);
151 A->setOwnsValues(
true);
157 if (SpellingSize != ArgStringSize)
161 if (Index >
Args.getNumInputArgStrings() ||
162 Args.getArgString(Index - 1) ==
nullptr)
165 return std::make_unique<Arg>(*
this, Spelling, Index - 2,
166 Args.getArgString(Index - 1));
169 if (SpellingSize != ArgStringSize)
173 if (Index >
Args.getNumInputArgStrings())
176 auto A = std::make_unique<Arg>(*
this, Spelling, Index - 1 -
getNumArgs(),
184 if (SpellingSize != ArgStringSize) {
185 const char *
Value =
Args.getArgString(Index) + SpellingSize;
186 return std::make_unique<Arg>(*
this, Spelling, Index++,
Value);
191 if (Index >
Args.getNumInputArgStrings() ||
192 Args.getArgString(Index - 1) ==
nullptr)
195 return std::make_unique<Arg>(*
this, Spelling, Index - 2,
196 Args.getArgString(Index - 1));
201 if (Index >
Args.getNumInputArgStrings() ||
202 Args.getArgString(Index - 1) ==
nullptr)
205 return std::make_unique<Arg>(*
this, Spelling, Index - 2,
206 Args.getArgString(Index - 2) + SpellingSize,
207 Args.getArgString(Index - 1));
210 if (SpellingSize != ArgStringSize)
212 auto A = std::make_unique<Arg>(*
this, Spelling, Index++);
213 while (Index <
Args.getNumInputArgStrings() &&
214 Args.getArgString(Index) !=
nullptr)
215 A->getValues().push_back(
Args.getArgString(Index++));
219 auto A = std::make_unique<Arg>(*
this, Spelling, Index);
220 if (SpellingSize != ArgStringSize) {
222 A->getValues().push_back(
Args.getArgString(Index) + SpellingSize);
225 while (Index <
Args.getNumInputArgStrings() &&
226 Args.getArgString(Index) !=
nullptr)
227 A->getValues().push_back(
Args.getArgString(Index++));
237 bool GroupedShortOption,
238 unsigned &Index)
const {
240 ? std::make_unique<Arg>(*
this, CurArg, Index)
241 : acceptInternal(Args, CurArg, Index));
258 StringRef UnaliasedSpelling = Args.MakeArgString(
267 std::make_unique<Arg>(UnaliasedOption, UnaliasedSpelling,
A->getIndex());
269 UnaliasedA->setAlias(std::move(
A));
277 UnaliasedA->getValues() = RawA->
getValues();
285 while (*Val !=
'\0') {
286 UnaliasedA->getValues().push_back(Val);
289 Val += strlen(Val) + 1;
294 UnaliasedA->getValues().push_back(
"");
Defines the llvm::Arg class for parsed arguments.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Analysis containing CSE Info
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
ArgList - Ordered collection of driver arguments.
A concrete instance of a particular driver option.
bool getOwnsValues() const
SmallVectorImpl< const char * > & getValues()
void setOwnsValues(bool Value) const
OptSpecifier - Wrapper class for abstracting references to option IDs.
Provide access to the Option info table.
const char * getStrTable() const
Return the string table used for option names.
ArrayRef< unsigned > getPrefixesTable() const
Return the prefixes table used for option names.
Option - Abstract representation for a single form of driver argument.
const Option getAlias() const
unsigned getNumArgs() const
const char * getAliasArgs() const
Get the alias arguments as a \0 separated list.
const Option getGroup() const
const Option getUnaliasedOption() const
getUnaliasedOption - Return the final option this option aliases (itself, if the option has no alias)...
bool matches(OptSpecifier ID) const
matches - Predicate for whether this option is part of the given option (which may be a group).
Option(const OptTable::Info *Info, const OptTable *Owner)
@ RemainingArgsJoinedClass
StringRef getPrefix() const
Get the default prefix for this option.
const OptTable::Info * Info
StringRef getName() const
Get the name of this option without any prefix.
std::unique_ptr< Arg > accept(const ArgList &Args, StringRef CurArg, bool GroupedShortOption, unsigned &Index) const
Potentially accept the current argument, returning a new Arg instance, or 0 if the option does not ac...
OptionClass getKind() const
void print(raw_ostream &O, bool AddNewLine=true) const
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Entry for a single option instance in the option data table.
unsigned getNumPrefixes(ArrayRef< unsigned > PrefixesTable) const
StringRef getPrefix(const char *StrTable, ArrayRef< unsigned > PrefixesTable, unsigned PrefixIndex) const