}
}
-Option::~Option() {
-}
-
void Option::dump() const {
llvm::errs() << "<";
switch (getKind()) {
if (Info->Prefixes) {
llvm::errs() << " Prefixes:[";
- for (const char * const *Pre = Info->Prefixes; *Pre != 0; ++Pre) {
- llvm::errs() << '"' << *Pre << (*(Pre + 1) == 0 ? "\"" : "\", ");
+ for (const char * const *Pre = Info->Prefixes; *Pre != nullptr; ++Pre) {
+ llvm::errs() << '"' << *Pre << (*(Pre + 1) == nullptr ? "\"" : "\", ");
}
llvm::errs() << ']';
}
switch (getKind()) {
case FlagClass: {
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
if (getAliasArgs()) {
Val += strlen(Val) + 1;
}
}
+
+ if (UnaliasedOption.getKind() == JoinedClass && !getAliasArgs())
+ // A Flag alias for a Joined option must provide an argument.
+ A->getValues().push_back("");
+
return A;
}
case JoinedClass: {
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Index += 2;
- if (Index > Args.getNumInputArgStrings())
- return 0;
+ if (Index > Args.getNumInputArgStrings() ||
+ Args.getArgString(Index - 1) == nullptr)
+ return nullptr;
return new Arg(UnaliasedOption, Spelling,
Index - 2, Args.getArgString(Index - 1));
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Index += 1 + getNumArgs();
if (Index > Args.getNumInputArgStrings())
- return 0;
+ return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index - 1 - getNumArgs(),
Args.getArgString(Index - getNumArgs()));
// Otherwise it must be separate.
Index += 2;
- if (Index > Args.getNumInputArgStrings())
- return 0;
+ if (Index > Args.getNumInputArgStrings() ||
+ Args.getArgString(Index - 1) == nullptr)
+ return nullptr;
return new Arg(UnaliasedOption, Spelling,
Index - 2, Args.getArgString(Index - 1));
case JoinedAndSeparateClass:
// Always matches.
Index += 2;
- if (Index > Args.getNumInputArgStrings())
- return 0;
+ if (Index > Args.getNumInputArgStrings() ||
+ Args.getArgString(Index - 1) == nullptr)
+ return nullptr;
return new Arg(UnaliasedOption, Spelling, Index - 2,
Args.getArgString(Index - 2) + ArgSize,
// Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (ArgSize != strlen(Args.getArgString(Index)))
- return 0;
+ return nullptr;
Arg *A = new Arg(UnaliasedOption, Spelling, Index++);
- while (Index < Args.getNumInputArgStrings())
+ while (Index < Args.getNumInputArgStrings() &&
+ Args.getArgString(Index) != nullptr)
A->getValues().push_back(Args.getArgString(Index++));
return A;
}