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

Chris Lattner sabre at nondot.org
Wed Apr 11 17:36:52 PDT 2007



Changes in directory llvm/lib/Support:

CommandLine.cpp updated: 1.86 -> 1.87
---
Log message:

improve the patch for PR1318: http://llvm.org/PR1318  to also support grouped options with custom
handlers (like the pass list).  My previous fix only supported *new* command
line options, not additions to old ones.

This fixes test/Feature/load_module.ll


---
Diffs of the changes:  (+12 -7)

 CommandLine.cpp |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)


Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.86 llvm/lib/Support/CommandLine.cpp:1.87
--- llvm/lib/Support/CommandLine.cpp:1.86	Wed Apr 11 10:35:18 2007
+++ llvm/lib/Support/CommandLine.cpp	Wed Apr 11 19:36:29 2007
@@ -71,6 +71,13 @@
   MoreHelp->push_back(Help);
 }
 
+static bool OptionListChanged = false;
+
+// MarkOptionsChanged - Internal helper function.
+void cl::MarkOptionsChanged() {
+  OptionListChanged = true;
+}
+
 /// RegisteredOptionList - This is the list of the command line options that
 /// have statically constructed themselves.
 static Option *RegisteredOptionList = 0;
@@ -80,8 +87,10 @@
   
   NextRegistered = RegisteredOptionList;
   RegisteredOptionList = this;
+  MarkOptionsChanged();
 }
 
+
 //===----------------------------------------------------------------------===//
 // Basic, shared command line option processing machinery.
 //
@@ -394,10 +403,6 @@
   // the positional args into the PositionalVals list...
   Option *ActivePositionalArg = 0;
 
-  // Keep track of the option list so far so that we can tell if it is ever
-  // extended.
-  Option *CurOptionList = RegisteredOptionList;
-  
   // Loop over all of the arguments... processing them.
   bool DashDashFound = false;  // Have we read '--'?
   for (int i = 1; i < argc; ++i) {
@@ -405,14 +410,14 @@
     const char *Value = 0;
     const char *ArgName = "";
 
-    // If the head of the option list changed, this means that some command line
+    // If the option list changed, this means that some command line
     // option has just been registered or deregistered.  This can occur in
     // response to things like -load, etc.  If this happens, rescan the options.
-    if (CurOptionList != RegisteredOptionList) {
+    if (OptionListChanged) {
       PositionalOpts.clear();
       Opts.clear();
       GetOptionInfo(PositionalOpts, Opts);
-      CurOptionList = RegisteredOptionList;
+      OptionListChanged = false;
     }
     
     // Check to see if this is a positional argument.  This argument is






More information about the llvm-commits mailing list