summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-07 05:38:53 +0000
committerChris Lattner <sabre@nondot.org>2007-04-07 05:38:53 +0000
commit0e1c1d4ae3a0c848dd23e57bddd1756b5201c6d5 (patch)
tree18cc622eebcf2f4e71ff4392c27a9f56ea4bbd10 /llvm/lib/Support
parentf095bf3ac4e410441f69491591413189a3ac828a (diff)
downloadbcm5719-llvm-0e1c1d4ae3a0c848dd23e57bddd1756b5201c6d5.tar.gz
bcm5719-llvm-0e1c1d4ae3a0c848dd23e57bddd1756b5201c6d5.zip
Fix a bug in my earlier commit which exposed positional options backwards.
This fixes llvm-ar. llvm-svn: 35727
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/CommandLine.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index e349eaa514c..768bd6c05b6 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -91,6 +91,7 @@ void Option::addArgument() {
static void GetOptionInfo(std::vector<Option*> &PositionalOpts,
std::map<std::string, Option*> &OptionsMap) {
std::vector<const char*> OptionNames;
+ Option *CAOpt = 0; // The ConsumeAfter option if it exists.
for (Option *O = RegisteredOptionList; O; O = O->getNextRegisteredOption()) {
// If this option wants to handle multiple option names, get the full set.
// This handles enum options like "-O1 -O2" etc.
@@ -114,12 +115,17 @@ static void GetOptionInfo(std::vector<Option*> &PositionalOpts,
if (O->getFormattingFlag() == cl::Positional)
PositionalOpts.push_back(O);
else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) {
- if (!PositionalOpts.empty() &&
- PositionalOpts.front()->getNumOccurrencesFlag() == cl::ConsumeAfter)
+ if (CAOpt)
O->error("Cannot specify more than one option with cl::ConsumeAfter!");
- PositionalOpts.insert(PositionalOpts.begin(), O);
+ CAOpt = O;
}
}
+
+ if (CAOpt)
+ PositionalOpts.push_back(CAOpt);
+
+ // Make sure that they are in order of registration not backwards.
+ std::reverse(PositionalOpts.begin(), PositionalOpts.end());
}
OpenPOWER on IntegriCloud