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
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index 8d2138d..c6c1ee6 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -27,38 +27,41 @@
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 @@
Res = A2;
}
- if (Claim && Res)
+ if (Res)
Res->claim();
return Res;
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index ce1ac3b..e0cc9a7 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -687,7 +687,7 @@
//
// Otherwise emit an error but still use a valid type to avoid
// spurious errors (e.g., no inputs).
- if (!Args.hasArg(options::OPT_E, false))
+ if (!Args.hasArgNoClaim(options::OPT_E))
Diag(clang::diag::err_drv_unknown_stdin_type);
Ty = types::TY_C;
} else {
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 296e399..8242d31 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -304,9 +304,9 @@
// and try to push it down into tool specific logic.
Arg *OSXVersion =
- Args.getLastArg(options::OPT_mmacosx_version_min_EQ, false);
+ Args.getLastArgNoClaim(options::OPT_mmacosx_version_min_EQ);
Arg *iPhoneVersion =
- Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false);
+ Args.getLastArgNoClaim(options::OPT_miphoneos_version_min_EQ);
if (OSXVersion && iPhoneVersion) {
getHost().getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with)
<< OSXVersion->getAsString(Args)
@@ -440,7 +440,7 @@
if (getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64)
- if (!Args.hasArg(options::OPT_mtune_EQ, false))
+ if (!Args.hasArgNoClaim(options::OPT_mtune_EQ))
DAL->append(DAL->MakeJoinedArg(0, Opts.getOption(options::OPT_mtune_EQ),
"core2"));
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index d42751b..15e5f3f 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -864,7 +864,7 @@
CmdArgs.push_back(A->getValue(Args));
}
- if (Args.hasArg(options::OPT__relocatable_pch, true))
+ if (Args.hasArg(options::OPT__relocatable_pch))
CmdArgs.push_back("--relocatable-pch");
if (Arg *A = Args.getLastArg(options::OPT_fconstant_string_class_EQ)) {