[llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp

Chris Lattner sabre at nondot.org
Fri Apr 6 22:39:11 PDT 2007



Changes in directory llvm/lib/Support:

CommandLine.cpp updated: 1.84 -> 1.85
---
Log message:

Fix a bug in my earlier commit which exposed positional options backwards.
This fixes llvm-ar.



---
Diffs of the changes:  (+9 -3)

 CommandLine.cpp |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)


Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.84 llvm/lib/Support/CommandLine.cpp:1.85
--- llvm/lib/Support/CommandLine.cpp:1.84	Fri Apr  6 16:06:55 2007
+++ llvm/lib/Support/CommandLine.cpp	Sat Apr  7 00:38:53 2007
@@ -91,6 +91,7 @@
 static void GetOptionInfo(std::vector<Option*> &PositionalOpts,
                           std::map<std::string, Option*> &OptionsMap) {
   std::vector<const char*> OptionNames;
+  Option *CAOpt = 0;  // The ConsumeAfter option if it exists.
   for (Option *O = RegisteredOptionList; O; O = O->getNextRegisteredOption()) {
     // If this option wants to handle multiple option names, get the full set.
     // This handles enum options like "-O1 -O2" etc.
@@ -114,12 +115,17 @@
     if (O->getFormattingFlag() == cl::Positional)
       PositionalOpts.push_back(O);
     else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) {
-      if (!PositionalOpts.empty() &&
-          PositionalOpts.front()->getNumOccurrencesFlag() == cl::ConsumeAfter)
+      if (CAOpt)
         O->error("Cannot specify more than one option with cl::ConsumeAfter!");
-      PositionalOpts.insert(PositionalOpts.begin(), O);
+      CAOpt = O;
     }
   }
+  
+  if (CAOpt)
+    PositionalOpts.push_back(CAOpt);
+  
+  // Make sure that they are in order of registration not backwards.
+  std::reverse(PositionalOpts.begin(), PositionalOpts.end());
 }
 
 






More information about the llvm-commits mailing list