aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/ArgList.h5
-rw-r--r--lib/Driver/ArgList.cpp6
2 files changed, 7 insertions, 4 deletions
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h
index 4131ff4d16..2e47ee4c39 100644
--- a/include/clang/Driver/ArgList.h
+++ b/include/clang/Driver/ArgList.h
@@ -58,7 +58,10 @@ namespace driver {
const char *getArgString(unsigned Index) const { return ArgStrings[Index]; }
/// hasArg - Does the arg list contain any option matching \arg Id.
- bool hasArg(options::ID Id) const;
+ bool hasArg(options::ID Id) const { return getLastArg(Id) != 0; }
+
+ /// getLastArg - Return the last argument matching \arg Id, or null.
+ Arg *getLastArg(options::ID Id) const;
};
} // end namespace driver
} // end namespace clang
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index aaba406f14..e29977fb0e 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -30,13 +30,13 @@ void ArgList::append(Arg *A) {
Args.push_back(A);
}
-bool ArgList::hasArg(options::ID Id) const {
+Arg *ArgList::getLastArg(options::ID Id) const {
// FIXME: Make search efficient?
// FIXME: This needs to not require loading of the option.
for (const_iterator it = begin(), ie = end(); it != ie; ++it)
if ((*it)->getOption().matches(Id))
- return true;
+ return *it;
- return false;
+ return 0;
}