]> granicus.if.org Git - clang/commitdiff
Driver: Add ArgList::getLastArg.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 12 Mar 2009 16:03:38 +0000 (16:03 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 12 Mar 2009 16:03:38 +0000 (16:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66794 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/ArgList.h
lib/Driver/ArgList.cpp

index 4131ff4d168f91434e47746740788aa90c578172..2e47ee4c3948a91a1be2c848996b63152c0b9b11 100644 (file)
@@ -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
index aaba406f14923d679ade778b694719592a30c7a5..e29977fb0e9f73f23d67e6e107711c228c444838 100644 (file)
@@ -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;
 }