[docs] Fix duplicate arguments for JoinedAndSeparate
We can't see how many arguments are in the meta var name, so just assume that it is the right number. Differential Revision: https://reviews.llvm.org/D42840 llvm-svn: 325805
This commit is contained in:
parent
b8237d2e2b
commit
3c7b136a82
|
@ -245,19 +245,27 @@ void emitOptionWithArgs(StringRef Prefix, const Record *Option,
|
||||||
void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
|
void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
|
||||||
// Find the arguments to list after the option.
|
// Find the arguments to list after the option.
|
||||||
unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
|
unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
|
||||||
|
bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
|
||||||
|
|
||||||
std::vector<std::string> Args;
|
std::vector<std::string> Args;
|
||||||
if (!Option->isValueUnset("MetaVarName"))
|
if (HasMetaVarName)
|
||||||
Args.push_back(Option->getValueAsString("MetaVarName"));
|
Args.push_back(Option->getValueAsString("MetaVarName"));
|
||||||
else if (NumArgs == 1)
|
else if (NumArgs == 1)
|
||||||
Args.push_back("<arg>");
|
Args.push_back("<arg>");
|
||||||
|
|
||||||
while (Args.size() < NumArgs) {
|
// Fill up arguments if this option didn't provide a meta var name or it
|
||||||
Args.push_back(("<arg" + Twine(Args.size() + 1) + ">").str());
|
// supports an unlimited number of arguments. We can't see how many arguments
|
||||||
// Use '--args <arg1> <arg2>...' if any number of args are allowed.
|
// already are in a meta var name, so assume it has right number. This is
|
||||||
if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
|
// needed for JoinedAndSeparate options so that there arent't too many
|
||||||
Args.back() += "...";
|
// arguments.
|
||||||
break;
|
if (!HasMetaVarName || NumArgs == UnlimitedArgs) {
|
||||||
|
while (Args.size() < NumArgs) {
|
||||||
|
Args.push_back(("<arg" + Twine(Args.size() + 1) + ">").str());
|
||||||
|
// Use '--args <arg1> <arg2>...' if any number of args are allowed.
|
||||||
|
if (Args.size() == 2 && NumArgs == UnlimitedArgs) {
|
||||||
|
Args.back() += "...";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue