12#include "llvm/Config/llvm-config.h"
31 "Multi-level aliases are not supported.");
37 "Cannot provide alias args to a flag option.");
44#define P(N) case N: O << #N; break
63 if (!
Info->hasNoPrefix()) {
65 for (
size_t I = 0,
N =
Info->getNumPrefixes(
Owner->getPrefixesTable());
69 << (
I ==
N - 1 ?
"\"" :
"\", ");
73 O <<
" Name:\"" <<
getName() <<
'"';
78 Group.
print(O,
false);
84 Alias.
print(O,
false);
95#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
115std::unique_ptr<Arg> Option::acceptInternal(
const ArgList &Args,
117 unsigned &Index)
const {
118 const size_t SpellingSize = CurArg.
size();
119 const size_t ArgStringSize =
StringRef(Args.getArgString(Index)).
size();
122 if (SpellingSize != ArgStringSize)
124 return std::make_unique<Arg>(*
this, CurArg, Index++);
127 const char *
Value = Args.getArgString(Index) + SpellingSize;
128 return std::make_unique<Arg>(*
this, CurArg, Index++,
Value);
132 const char *Str = Args.getArgString(Index) + SpellingSize;
133 auto A = std::make_unique<Arg>(*
this, CurArg, Index++);
136 const char *Prev = Str;
140 if (!c || c ==
',') {
142 char *
Value =
new char[Str - Prev + 1];
143 memcpy(
Value, Prev, Str - Prev);
144 Value[Str - Prev] =
'\0';
145 A->getValues().push_back(
Value);
154 A->setOwnsValues(
true);
160 if (SpellingSize != ArgStringSize)
164 if (Index >
Args.getNumInputArgStrings() ||
165 Args.getArgString(Index - 1) ==
nullptr)
168 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
169 Args.getArgString(Index - 1));
172 if (SpellingSize != ArgStringSize)
176 if (Index >
Args.getNumInputArgStrings())
179 auto A = std::make_unique<Arg>(*
this, CurArg, Index - 1 -
getNumArgs(),
187 if (SpellingSize != ArgStringSize) {
188 const char *
Value =
Args.getArgString(Index) + SpellingSize;
189 return std::make_unique<Arg>(*
this, CurArg, Index++,
Value);
194 if (Index >
Args.getNumInputArgStrings() ||
195 Args.getArgString(Index - 1) ==
nullptr)
198 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
199 Args.getArgString(Index - 1));
204 if (Index >
Args.getNumInputArgStrings() ||
205 Args.getArgString(Index - 1) ==
nullptr)
208 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
209 Args.getArgString(Index - 2) + SpellingSize,
210 Args.getArgString(Index - 1));
213 if (SpellingSize != ArgStringSize)
215 auto A = std::make_unique<Arg>(*
this, CurArg, Index++);
216 while (Index <
Args.getNumInputArgStrings() &&
217 Args.getArgString(Index) !=
nullptr)
218 A->getValues().push_back(
Args.getArgString(Index++));
223 const char *Rest =
Args.getArgString(Index) + SpellingSize;
225 return std::make_unique<Arg>(*
this, CurArg, Index++, Rest + 1);
229 return std::make_unique<Arg>(*
this, CurArg, Index++);
232 if (Index >
Args.getNumInputArgStrings() ||
233 Args.getArgString(Index - 1) ==
nullptr)
235 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
236 Args.getArgString(Index - 1));
239 auto A = std::make_unique<Arg>(*
this, CurArg, Index);
240 if (SpellingSize != ArgStringSize) {
242 A->getValues().push_back(
Args.getArgString(Index) + SpellingSize);
245 while (Index <
Args.getNumInputArgStrings() &&
246 Args.getArgString(Index) !=
nullptr)
247 A->getValues().push_back(
Args.getArgString(Index++));
257 bool GroupedShortOption,
258 unsigned &Index)
const {
260 ? std::make_unique<Arg>(*
this, CurArg, Index)
261 : acceptInternal(Args, CurArg, Index));
278 StringRef UnaliasedSpelling = Args.MakeArgString(
287 std::make_unique<Arg>(UnaliasedOption, UnaliasedSpelling,
A->getIndex());
289 UnaliasedA->setAlias(std::move(
A));
297 UnaliasedA->getValues() = RawA->
getValues();
304 for (
const char *Val =
getAliasArgs(); *Val; Val += strlen(Val) + 1)
305 UnaliasedA->getValues().push_back(Val);
308 UnaliasedA->getValues().push_back(
"");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Defines the llvm::Arg class for parsed arguments.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Represent a constant reference to a string, i.e.
constexpr size_t size() const
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 Option getAlias() const
LLVM_ABI void dump() 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)...
LLVM_ABI bool matches(OptSpecifier ID) const
matches - Predicate for whether this option is part of the given option (which may be a group).
LLVM_ABI Option(const OptTable::Info *Info, const OptTable *Owner)
@ RemainingArgsJoinedClass
bool hasAliasArgs() const
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.
LLVM_ABI 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
LLVM_ABI 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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI 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.