Driver: ArgList::getLastArg was in fact returning the first matching arg.
- <rdar://problem/6715818> clang doesn't honor gcc semantic that last
-O optimization option wins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67628 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index 7653daf..d74e3bd 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -34,9 +34,7 @@
Arg *ArgList::getLastArg(options::ID Id, bool Claim) 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) {
+ for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it) {
if ((*it)->getOption().matches(Id)) {
if (Claim) (*it)->claim();
return *it;