[cfe-commits] r89308 - in /cfe/trunk: include/clang/Driver/ArgList.h lib/Driver/ArgList.cpp lib/Driver/Driver.cpp lib/Driver/ToolChains.cpp lib/Driver/Tools.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 18 20:00:53 PST 2009
Author: ddunbar
Date: Wed Nov 18 22:00:53 2009
New Revision: 89308
URL: http://llvm.org/viewvc/llvm-project?rev=89308&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Driver/ArgList.h
cfe/trunk/lib/Driver/ArgList.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/ArgList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ArgList.h?rev=89308&r1=89307&r2=89308&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Wed Nov 18 22:00:53 2009
@@ -78,20 +78,27 @@
/// hasArg - Does the arg list contain any option matching \arg Id.
///
/// \arg Claim Whether the argument should be claimed, if it exists.
- bool hasArg(options::ID Id, bool Claim=true) const {
- return getLastArg(Id, Claim) != 0;
+ bool hasArgNoClaim(options::ID Id) const {
+ return getLastArgNoClaim(Id) != 0;
}
- bool hasArg(options::ID Id0, options::ID Id1, bool Claim=true) const {
- return getLastArg(Id0, Id1, Claim) != 0;
+ bool hasArg(options::ID Id) const {
+ return getLastArg(Id) != 0;
+ }
+ bool hasArg(options::ID Id0, options::ID Id1) const {
+ return getLastArg(Id0, Id1) != 0;
+ }
+ bool hasArg(options::ID Id0, options::ID Id1, options::ID Id2) const {
+ return getLastArg(Id0, Id1, Id2) != 0;
}
/// getLastArg - Return the last argument matching \arg Id, or null.
///
/// \arg Claim Whether the argument should be claimed, if it exists.
- Arg *getLastArg(options::ID Id, bool Claim=true) const;
- Arg *getLastArg(options::ID Id0, options::ID Id1, bool Claim=true) const;
- Arg *getLastArg(options::ID Id0, options::ID Id1, options::ID Id2,
- bool Claim=true) const;
+ Arg *getLastArgNoClaim(options::ID Id) const;
+ Arg *getLastArg(options::ID Id) const;
+ Arg *getLastArg(options::ID Id0, options::ID Id1) const;
+ Arg *getLastArg(options::ID Id0, options::ID Id1,
+ options::ID Id2) const;
/// getArgString - Return the input argument string at \arg Index.
virtual const char *getArgString(unsigned Index) const = 0;
Modified: cfe/trunk/lib/Driver/ArgList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ArgList.cpp?rev=89308&r1=89307&r2=89308&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ArgList.cpp (original)
+++ cfe/trunk/lib/Driver/ArgList.cpp Wed Nov 18 22:00:53 2009
@@ -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;
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=89308&r1=89307&r2=89308&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov 18 22:00:53 2009
@@ -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 {
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=89308&r1=89307&r2=89308&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Nov 18 22:00:53 2009
@@ -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"));
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=89308&r1=89307&r2=89308&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Nov 18 22:00:53 2009
@@ -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)) {
More information about the cfe-commits
mailing list