aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/ArgList.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-19 04:00:53 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-19 04:00:53 +0000
commite4bdae78c69d2a09ee96619cc5ccf81441674412 (patch)
treeef7e5fceb8c541419a1bcd7b0af4869636f673fb /lib/Driver/ArgList.cpp
parent88bd0094d8784b0a6a785ddeca18e5061417dcce (diff)
Driver: Switch to using explicit {getLast,has}ArgNoClaim functions instead of taking a Claim argument.
- Most driver code always claims, and bool arguments don't play nice with the overloads. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ArgList.cpp')
-rw-r--r--lib/Driver/ArgList.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index 8d2138df85..c6c1ee60da 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -27,38 +27,41 @@ void ArgList::append(Arg *A) {
Args.push_back(A);
}
-Arg *ArgList::getLastArg(options::ID Id, bool Claim) const {
+Arg *ArgList::getLastArgNoClaim(options::ID Id) const {
// FIXME: Make search efficient?
- for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) {
- if ((*it)->getOption().matches(Id)) {
- if (Claim) (*it)->claim();
+ for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
+ if ((*it)->getOption().matches(Id))
return *it;
- }
- }
-
return 0;
}
-Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, bool Claim) const {
- Arg *Res, *A0 = getLastArg(Id0, false), *A1 = getLastArg(Id1, false);
+Arg *ArgList::getLastArg(options::ID Id) const {
+ Arg *A = getLastArgNoClaim(Id);
+ if (A)
+ A->claim();
+ return A;
+}
+
+Arg *ArgList::getLastArg(options::ID Id0, options::ID 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;
- if (Claim && Res)
+ if (Res)
Res->claim();
return Res;
}
-Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, options::ID Id2,
- bool Claim) const {
+Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1,
+ options::ID Id2) const {
Arg *Res = 0;
- Arg *A0 = getLastArg(Id0, false);
- Arg *A1 = getLastArg(Id1, false);
- Arg *A2 = getLastArg(Id2, false);
+ Arg *A0 = getLastArgNoClaim(Id0);
+ Arg *A1 = getLastArgNoClaim(Id1);
+ Arg *A2 = getLastArgNoClaim(Id2);
int A0Idx = A0 ? A0->getIndex() : -1;
int A1Idx = A1 ? A1->getIndex() : -1;
@@ -76,7 +79,7 @@ Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, options::ID Id2,
Res = A2;
}
- if (Claim && Res)
+ if (Res)
Res->claim();
return Res;