aboutsummaryrefslogtreecommitdiff
path: root/utils/TableGen/ClangOptionDocEmitter.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:06:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:06:01 +0000
commit486754660bb926339aefcf012a3f848592babb8b (patch)
treeecdbc446c9876f4f120f701c243373cd3cb43db3 /utils/TableGen/ClangOptionDocEmitter.cpp
parent55e6d896ad333f07bb3b1ba487df214fc268a4ab (diff)
downloadsrc-486754660bb926339aefcf012a3f848592babb8b.tar.gz
src-486754660bb926339aefcf012a3f848592babb8b.zip
Vendor import of clang trunk r338150:vendor/clang/clang-trunk-r338150
Notes
Notes: svn path=/vendor/clang/dist/; revision=336815 svn path=/vendor/clang/clang-trunk-r338150/; revision=336816; tag=vendor/clang/clang-trunk-r338150
Diffstat (limited to 'utils/TableGen/ClangOptionDocEmitter.cpp')
-rw-r--r--utils/TableGen/ClangOptionDocEmitter.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/utils/TableGen/ClangOptionDocEmitter.cpp b/utils/TableGen/ClangOptionDocEmitter.cpp
index 59314510e0ad..7fe487e54698 100644
--- a/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -111,7 +111,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
auto DocumentationForOption = [&](Record *R) -> DocumentedOption {
auto &A = Aliases[R];
- std::sort(A.begin(), A.end(), CompareByName);
+ llvm::sort(A.begin(), A.end(), CompareByName);
return {R, std::move(A)};
};
@@ -120,7 +120,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
Documentation D;
auto &Groups = GroupsInGroup[R];
- std::sort(Groups.begin(), Groups.end(), CompareByLocation);
+ llvm::sort(Groups.begin(), Groups.end(), CompareByLocation);
for (Record *G : Groups) {
D.Groups.emplace_back();
D.Groups.back().Group = G;
@@ -129,7 +129,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
}
auto &Options = OptionsInGroup[R];
- std::sort(Options.begin(), Options.end(), CompareByName);
+ llvm::sort(Options.begin(), Options.end(), CompareByName);
for (Record *O : Options)
D.Options.push_back(DocumentationForOption(O));
@@ -245,19 +245,27 @@ void emitOptionWithArgs(StringRef Prefix, const Record *Option,
void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
// Find the arguments to list after the option.
unsigned NumArgs = getNumArgsForKind(Option->getValueAsDef("Kind"), Option);
+ bool HasMetaVarName = !Option->isValueUnset("MetaVarName");
std::vector<std::string> Args;
- if (!Option->isValueUnset("MetaVarName"))
+ if (HasMetaVarName)
Args.push_back(Option->getValueAsString("MetaVarName"));
else if (NumArgs == 1)
Args.push_back("<arg>");
- 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;
+ // Fill up arguments if this option didn't provide a meta var name or it
+ // supports an unlimited number of arguments. We can't see how many arguments
+ // already are in a meta var name, so assume it has right number. This is
+ // needed for JoinedAndSeparate options so that there arent't too many
+ // arguments.
+ 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;
+ }
}
}