aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/ArgList.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-06-14 20:20:44 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-06-14 20:20:44 +0000
commitfdbe65e587b85cf48f093d531a78fa3b2d9961b8 (patch)
treea0960b5b8356f943eb3c3b97b3cc11c0523a300f /lib/Driver/ArgList.cpp
parent9d0863b22faef1678eb191bbab7268809be60a96 (diff)
Driver: Fix refacto in DerivedArgList::MakeSeparateArg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ArgList.cpp')
-rw-r--r--lib/Driver/ArgList.cpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index 46573022c5..95fef89b85 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -62,12 +62,14 @@ Arg *ArgList::getLastArg(OptSpecifier Id) const {
}
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
- Arg *Res, *A0 = getLastArgNoClaim(Id0), *A1 = getLastArgNoClaim(Id1);
-
- if (A0 && A1)
- Res = A0->getIndex() > A1->getIndex() ? A0 : A1;
- else
- Res = A0 ? A0 : A1;
+ Arg *Res = 0;
+ for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) {
+ if ((*it)->getOption().matches(Id0) ||
+ (*it)->getOption().matches(Id1)) {
+ Res = *it;
+ break;
+ }
+ }
if (Res)
Res->claim();
@@ -78,24 +80,13 @@ Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1) const {
Arg *ArgList::getLastArg(OptSpecifier Id0, OptSpecifier Id1,
OptSpecifier Id2) const {
Arg *Res = 0;
- Arg *A0 = getLastArgNoClaim(Id0);
- Arg *A1 = getLastArgNoClaim(Id1);
- Arg *A2 = getLastArgNoClaim(Id2);
-
- int A0Idx = A0 ? (int) A0->getIndex() : -1;
- int A1Idx = A1 ? (int) A1->getIndex() : -1;
- int A2Idx = A2 ? (int) A2->getIndex() : -1;
-
- if (A0Idx > A1Idx) {
- if (A0Idx > A2Idx)
- Res = A0;
- else if (A2Idx != -1)
- Res = A2;
- } else {
- if (A1Idx > A2Idx)
- Res = A1;
- else if (A2Idx != -1)
- Res = A2;
+ for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) {
+ if ((*it)->getOption().matches(Id0) ||
+ (*it)->getOption().matches(Id1) ||
+ (*it)->getOption().matches(Id2)) {
+ Res = *it;
+ break;
+ }
}
if (Res)
@@ -272,7 +263,7 @@ Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt,
Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
llvm::StringRef Value) const {
unsigned Index = BaseArgs.MakeIndex(Opt->getName(), Value);
- Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index), BaseArg);
+ Arg *A = new Arg(Opt, Index, BaseArgs.getArgString(Index + 1), BaseArg);
SynthesizedArgs.push_back(A);
return A;
}