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
61 if (!
Info->hasNoPrefix()) {
63 for (
size_t I = 0,
N =
Info->getNumPrefixes(
Owner->getPrefixesTable());
67 << (
I ==
N - 1 ?
"\"" :
"\", ");
71 O <<
" Name:\"" <<
getName() <<
'"';
76 Group.
print(O,
false);
82 Alias.
print(O,
false);
93#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
113std::unique_ptr<Arg> Option::acceptInternal(
const ArgList &Args,
115 unsigned &Index)
const {
116 const size_t SpellingSize = CurArg.
size();
117 const size_t ArgStringSize =
StringRef(Args.getArgString(Index)).
size();
120 if (SpellingSize != ArgStringSize)
122 return std::make_unique<Arg>(*
this, CurArg, Index++);
125 const char *
Value = Args.getArgString(Index) + SpellingSize;
126 return std::make_unique<Arg>(*
this, CurArg, Index++,
Value);
130 const char *Str = Args.getArgString(Index) + SpellingSize;
131 auto A = std::make_unique<Arg>(*
this, CurArg, Index++);
134 const char *Prev = Str;
138 if (!c || c ==
',') {
140 char *
Value =
new char[Str - Prev + 1];
141 memcpy(
Value, Prev, Str - Prev);
142 Value[Str - Prev] =
'\0';
143 A->getValues().push_back(
Value);
152 A->setOwnsValues(
true);
158 if (SpellingSize != ArgStringSize)
162 if (Index >
Args.getNumInputArgStrings() ||
163 Args.getArgString(Index - 1) ==
nullptr)
166 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
167 Args.getArgString(Index - 1));
170 if (SpellingSize != ArgStringSize)
174 if (Index >
Args.getNumInputArgStrings())
177 auto A = std::make_unique<Arg>(*
this, CurArg, Index - 1 -
getNumArgs(),
185 if (SpellingSize != ArgStringSize) {
186 const char *
Value =
Args.getArgString(Index) + SpellingSize;
187 return std::make_unique<Arg>(*
this, CurArg, Index++,
Value);
192 if (Index >
Args.getNumInputArgStrings() ||
193 Args.getArgString(Index - 1) ==
nullptr)
196 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
197 Args.getArgString(Index - 1));
202 if (Index >
Args.getNumInputArgStrings() ||
203 Args.getArgString(Index - 1) ==
nullptr)
206 return std::make_unique<Arg>(*
this, CurArg, Index - 2,
207 Args.getArgString(Index - 2) + SpellingSize,
208 Args.getArgString(Index - 1));
211 if (SpellingSize != ArgStringSize)
213 auto A = std::make_unique<Arg>(*
this, CurArg, Index++);
214 while (Index <
Args.getNumInputArgStrings() &&
215 Args.getArgString(Index) !=
nullptr)
216 A->getValues().push_back(
Args.getArgString(Index++));
220 auto A = std::make_unique<Arg>(*
this, CurArg, Index);
221 if (SpellingSize != ArgStringSize) {
223 A->getValues().push_back(
Args.getArgString(Index) + SpellingSize);
226 while (Index <
Args.getNumInputArgStrings() &&
227 Args.getArgString(Index) !=
nullptr)
228 A->getValues().push_back(
Args.getArgString(Index++));
238 bool GroupedShortOption,
239 unsigned &Index)
const {
241 ? std::make_unique<Arg>(*
this, CurArg, Index)
242 : acceptInternal(Args, CurArg, Index));
259 StringRef UnaliasedSpelling = Args.MakeArgString(
268 std::make_unique<Arg>(UnaliasedOption, UnaliasedSpelling,
A->getIndex());
270 UnaliasedA->setAlias(std::move(
A));
278 UnaliasedA->getValues() = RawA->
getValues();
285 for (
const char *Val =
getAliasArgs(); *Val; Val += strlen(Val) + 1)
286 UnaliasedA->getValues().push_back(Val);
289 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.