[cfe-commits] r67628 - in /cfe/trunk: include/clang/Driver/ArgList.h lib/Driver/ArgList.cpp test/Driver/clang-translation.c

Daniel Dunbar daniel at zuster.org
Tue Mar 24 10:31:30 PDT 2009


Author: ddunbar
Date: Tue Mar 24 12:31:30 2009
New Revision: 67628

URL: http://llvm.org/viewvc/llvm-project?rev=67628&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Driver/ArgList.h
    cfe/trunk/lib/Driver/ArgList.cpp
    cfe/trunk/test/Driver/clang-translation.c

Modified: cfe/trunk/include/clang/Driver/ArgList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ArgList.h?rev=67628&r1=67627&r2=67628&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Tue Mar 24 12:31:30 2009
@@ -32,6 +32,8 @@
     typedef llvm::SmallVector<Arg*, 16> arglist_type;
     typedef arglist_type::iterator iterator;
     typedef arglist_type::const_iterator const_iterator;
+    typedef arglist_type::reverse_iterator reverse_iterator;
+    typedef arglist_type::const_reverse_iterator const_reverse_iterator;
 
   private:
     /// List of argument strings used by the contained Args.
@@ -64,9 +66,15 @@
     iterator begin() { return Args.begin(); }
     iterator end() { return Args.end(); }
 
+    reverse_iterator rbegin() { return Args.rbegin(); }
+    reverse_iterator rend() { return Args.rend(); }
+
     const_iterator begin() const { return Args.begin(); }
     const_iterator end() const { return Args.end(); }
     
+    const_reverse_iterator rbegin() const { return Args.rbegin(); }
+    const_reverse_iterator rend() const { return Args.rend(); }
+    
     /// append - Append \arg A to the arg list, taking ownership.
     void append(Arg *A);
 

Modified: cfe/trunk/lib/Driver/ArgList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ArgList.cpp?rev=67628&r1=67627&r2=67628&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ArgList.cpp (original)
+++ cfe/trunk/lib/Driver/ArgList.cpp Tue Mar 24 12:31:30 2009
@@ -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;

Modified: cfe/trunk/test/Driver/clang-translation.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=67628&r1=67627&r2=67628&view=diff

==============================================================================
--- cfe/trunk/test/Driver/clang-translation.c (original)
+++ cfe/trunk/test/Driver/clang-translation.c Tue Mar 24 12:31:30 2009
@@ -1,4 +1,4 @@
-// RUN: clang -ccc-host-triple i386-unknown-unknown -### -S -Os %s -o %t.s 2> %t.log
+// RUN: clang -ccc-host-triple i386-unknown-unknown -### -S -O0 -Os %s -o %t.s 2> %t.log
 // RUN: grep '"-S"' %t.log &&
 // RUN: grep '"-disable-free"' %t.log &&
 // RUN: grep '"--relocation-model" "static"' %t.log &&





More information about the cfe-commits mailing list