diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-02-20 12:38:07 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-02-20 12:38:07 +0000 |
commit | d57160d097d6cdb966e5c851215acbd2bf1aa236 (patch) | |
tree | 94c96f66abfcf17623cd455bc3d205b8903e9ce4 /lib/Support/CommandLine.cpp | |
parent | c70d7734d30fe4f40206ebd17a1397ec789d4e9a (diff) |
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
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r-- | lib/Support/CommandLine.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index c70ed0da0c..4fe1aa1112 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -101,6 +101,7 @@ void Option::addArgument() { /// GetOptionInfo - Scan the list of registered options, turning them into data /// structures that are easier to handle. static void GetOptionInfo(std::vector<Option*> &PositionalOpts, + std::vector<Option*> &SinkOpts, std::map<std::string, Option*> &OptionsMap) { std::vector<const char*> OptionNames; Option *CAOpt = 0; // The ConsumeAfter option if it exists. @@ -126,6 +127,8 @@ static void GetOptionInfo(std::vector<Option*> &PositionalOpts, // Remember information about positional options. if (O->getFormattingFlag() == cl::Positional) PositionalOpts.push_back(O); + else if (O->getMiscFlags() && cl::Sink) // Remember sink options + SinkOpts.push_back(O); else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) { if (CAOpt) O->error("Cannot specify more than one option with cl::ConsumeAfter!"); @@ -337,8 +340,9 @@ void cl::ParseCommandLineOptions(int argc, char **argv, const char *Overview) { // Process all registered options. std::vector<Option*> PositionalOpts; + std::vector<Option*> SinkOpts; std::map<std::string, Option*> Opts; - GetOptionInfo(PositionalOpts, Opts); + GetOptionInfo(PositionalOpts, SinkOpts, Opts); assert((!Opts.empty() || !PositionalOpts.empty()) && "No options specified!"); @@ -418,8 +422,9 @@ void cl::ParseCommandLineOptions(int argc, char **argv, // response to things like -load, etc. If this happens, rescan the options. if (OptionListChanged) { PositionalOpts.clear(); + SinkOpts.clear(); Opts.clear(); - GetOptionInfo(PositionalOpts, Opts); + GetOptionInfo(PositionalOpts, SinkOpts, Opts); OptionListChanged = false; } @@ -515,9 +520,15 @@ void cl::ParseCommandLineOptions(int argc, char **argv, } if (Handler == 0) { - cerr << ProgramName << ": Unknown command line argument '" - << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; - ErrorParsing = true; + if (SinkOpts.empty()) { + cerr << ProgramName << ": Unknown command line argument '" + << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; + ErrorParsing = true; + } else { + for (std::vector<Option*>::iterator I = SinkOpts.begin(), + E = SinkOpts.end(); I != E ; ++I) + (*I)->addOccurrence(i, "", argv[i]); + } continue; } @@ -929,8 +940,9 @@ public: // Get all the options. std::vector<Option*> PositionalOpts; + std::vector<Option*> SinkOpts; std::map<std::string, Option*> OptMap; - GetOptionInfo(PositionalOpts, OptMap); + GetOptionInfo(PositionalOpts, SinkOpts, OptMap); // Copy Options into a vector so we can sort them as we like... std::vector<std::pair<std::string, Option*> > Opts; |