[PATCH] D42840: [docs] Fix duplicate arguments for JoinedAndSeparate

Jonas Hahnfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 09:11:18 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL325805: [docs] Fix duplicate arguments for JoinedAndSeparate (authored by Hahnfeld, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42840?vs=132559&id=135438#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42840

Files:
  cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
===================================================================
--- cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -245,19 +245,27 @@
 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;
+      }
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42840.135438.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180222/04b41442/attachment.bin>


More information about the llvm-commits mailing list