llvm.org GIT mirror llvm / 69d6f13
improve the patch for 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35935 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
2 changed file(s) with 18 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5555 /// on the command line. This gives other systems using the
5656 /// CommandLine utilities to print their own version string.
5757 void SetVersionPrinter(void (*func)());
58
59
60 // MarkOptionsChanged - Internal helper function.
61 void MarkOptionsChanged();
5862
5963 //===----------------------------------------------------------------------===//
6064 // Flags permitted to be passed to command line arguments
468472 assert(findOption(Name) == Values.size() && "Option already exists!");
469473 Values.push_back(std::make_pair(Name,
470474 std::make_pair(static_cast(V),HelpStr)));
475 MarkOptionsChanged();
471476 }
472477
473478 /// removeLiteralOption - Remove the specified option.
7070 MoreHelp->push_back(Help);
7171 }
7272
73 static bool OptionListChanged = false;
74
75 // MarkOptionsChanged - Internal helper function.
76 void cl::MarkOptionsChanged() {
77 OptionListChanged = true;
78 }
79
7380 /// RegisteredOptionList - This is the list of the command line options that
7481 /// have statically constructed themselves.
7582 static Option *RegisteredOptionList = 0;
7986
8087 NextRegistered = RegisteredOptionList;
8188 RegisteredOptionList = this;
82 }
89 MarkOptionsChanged();
90 }
91
8392
8493 //===----------------------------------------------------------------------===//
8594 // Basic, shared command line option processing machinery.
393402 // the positional args into the PositionalVals list...
394403 Option *ActivePositionalArg = 0;
395404
396 // Keep track of the option list so far so that we can tell if it is ever
397 // extended.
398 Option *CurOptionList = RegisteredOptionList;
399
400405 // Loop over all of the arguments... processing them.
401406 bool DashDashFound = false; // Have we read '--'?
402407 for (int i = 1; i < argc; ++i) {
404409 const char *Value = 0;
405410 const char *ArgName = "";
406411
407 // If the head of the option list changed, this means that some command line
412 // If the option list changed, this means that some command line
408413 // option has just been registered or deregistered. This can occur in
409414 // response to things like -load, etc. If this happens, rescan the options.
410 if (CurOptionList != RegisteredOptionList) {
415 if (OptionListChanged) {
411416 PositionalOpts.clear();
412417 Opts.clear();
413418 GetOptionInfo(PositionalOpts, Opts);
414 CurOptionList = RegisteredOptionList;
419 OptionListChanged = false;
415420 }
416421
417422 // Check to see if this is a positional argument. This argument is