[cfe-commits] r66794 - in /cfe/trunk: include/clang/Driver/ArgList.h lib/Driver/ArgList.cpp

Daniel Dunbar daniel at zuster.org
Thu Mar 12 09:03:38 PDT 2009


Author: ddunbar
Date: Thu Mar 12 11:03:38 2009
New Revision: 66794

URL: http://llvm.org/viewvc/llvm-project?rev=66794&view=rev
Log:
Driver: Add ArgList::getLastArg.

Modified:
    cfe/trunk/include/clang/Driver/ArgList.h
    cfe/trunk/lib/Driver/ArgList.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Thu Mar 12 11:03:38 2009
@@ -58,7 +58,10 @@
     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

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

==============================================================================
--- cfe/trunk/lib/Driver/ArgList.cpp (original)
+++ cfe/trunk/lib/Driver/ArgList.cpp Thu Mar 12 11:03:38 2009
@@ -30,13 +30,13 @@
   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;
 }





More information about the cfe-commits mailing list