llvm.org GIT mirror llvm / d57160d
Add 'sink' cmdline option. Patch by Mikhail Glushenkov! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47377 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 12 years ago
2 changed file(s) with 20 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
122122 enum MiscFlags { // Miscellaneous flags to adjust argument
123123 CommaSeparated = 0x200, // Should this cl::list split between commas?
124124 PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args?
125 MiscMask = 0x600 // Union of the above flags.
125 Sink = 0x800, // Should this cl::list eat all unknown options?
126 MiscMask = 0xE00 // Union of the above flags.
126127 };
127128
128129
100100 /// GetOptionInfo - Scan the list of registered options, turning them into data
101101 /// structures that are easier to handle.
102102 static void GetOptionInfo(std::vector &PositionalOpts,
103 std::vector &SinkOpts,
103104 std::map &OptionsMap) {
104105 std::vector OptionNames;
105106 Option *CAOpt = 0; // The ConsumeAfter option if it exists.
125126 // Remember information about positional options.
126127 if (O->getFormattingFlag() == cl::Positional)
127128 PositionalOpts.push_back(O);
129 else if (O->getMiscFlags() && cl::Sink) // Remember sink options
130 SinkOpts.push_back(O);
128131 else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) {
129132 if (CAOpt)
130133 O->error("Cannot specify more than one option with cl::ConsumeAfter!");
336339 const char *Overview) {
337340 // Process all registered options.
338341 std::vector PositionalOpts;
342 std::vector SinkOpts;
339343 std::map Opts;
340 GetOptionInfo(PositionalOpts, Opts);
344 GetOptionInfo(PositionalOpts, SinkOpts, Opts);
341345
342346 assert((!Opts.empty() || !PositionalOpts.empty()) &&
343347 "No options specified!");
417421 // response to things like -load, etc. If this happens, rescan the options.
418422 if (OptionListChanged) {
419423 PositionalOpts.clear();
424 SinkOpts.clear();
420425 Opts.clear();
421 GetOptionInfo(PositionalOpts, Opts);
426 GetOptionInfo(PositionalOpts, SinkOpts, Opts);
422427 OptionListChanged = false;
423428 }
424429
514519 }
515520
516521 if (Handler == 0) {
517 cerr << ProgramName << ": Unknown command line argument '"
518 << argv[i] << "'. Try: '" << argv[0] << " --help'\n";
519 ErrorParsing = true;
522 if (SinkOpts.empty()) {
523 cerr << ProgramName << ": Unknown command line argument '"
524 << argv[i] << "'. Try: '" << argv[0] << " --help'\n";
525 ErrorParsing = true;
526 } else {
527 for (std::vector::iterator I = SinkOpts.begin(),
528 E = SinkOpts.end(); I != E ; ++I)
529 (*I)->addOccurrence(i, "", argv[i]);
530 }
520531 continue;
521532 }
522533
928939
929940 // Get all the options.
930941 std::vector PositionalOpts;
942 std::vector SinkOpts;
931943 std::map OptMap;
932 GetOptionInfo(PositionalOpts, OptMap);
944 GetOptionInfo(PositionalOpts, SinkOpts, OptMap);
933945
934946 // Copy Options into a vector so we can sort them as we like...
935947 std::vector > Opts;