summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-11 15:35:18 +0000
committerChris Lattner <sabre@nondot.org>2007-04-11 15:35:18 +0000
commit83b53a59646d859776f818278ae9fef4daaff727 (patch)
tree79e0c09c9ef4c79b5d8178d69288fafba5a45a9f /llvm/lib/Support/CommandLine.cpp
parent7345e568856bfff416718ebdf6cb1a033804584b (diff)
downloadbcm5719-llvm-83b53a59646d859776f818278ae9fef4daaff727.tar.gz
bcm5719-llvm-83b53a59646d859776f818278ae9fef4daaff727.zip
Fix PR1318 by reacting appropriately to a mutating option list.
llvm-svn: 35905
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 768bd6c05b6..3d30e7a9f52 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -394,6 +394,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
// 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) {
@@ -401,6 +405,16 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
const char *Value = 0;
const char *ArgName = "";
+ // If the head of 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) {
+ PositionalOpts.clear();
+ Opts.clear();
+ GetOptionInfo(PositionalOpts, Opts);
+ CurOptionList = RegisteredOptionList;
+ }
+
// Check to see if this is a positional argument. This argument is
// considered to be positional if it doesn't start with '-', if it is "-"
// itself, or if we have seen "--" already.
OpenPOWER on IntegriCloud