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

Daniel Dunbar daniel at zuster.org
Wed Mar 11 18:36:44 PDT 2009


Author: ddunbar
Date: Wed Mar 11 20:36:44 2009
New Revision: 66758

URL: http://llvm.org/viewvc/llvm-project?rev=66758&view=rev
Log:
Driver: Add ArgList::hasArg, for testing for the presence of an
argument matching some Option::ID.

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=66758&r1=66757&r2=66758&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Wed Mar 11 20:36:44 2009
@@ -10,7 +10,9 @@
 #ifndef CLANG_DRIVER_ARGLIST_H_
 #define CLANG_DRIVER_ARGLIST_H_
 
-#include "Util.h"
+#include "clang/Driver/Options.h"
+
+#include "clang/Driver/Util.h"
 #include "llvm/ADT/SmallVector.h"
 
 namespace clang {
@@ -54,6 +56,9 @@
 
     /// getArgString - Return the input argument string at \arg Index.
     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;
   };
 } // 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=66758&r1=66757&r2=66758&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ArgList.cpp (original)
+++ cfe/trunk/lib/Driver/ArgList.cpp Wed Mar 11 20:36:44 2009
@@ -29,3 +29,14 @@
 
   Args.push_back(A);
 }
+
+bool ArgList::hasArg(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; ++ie)
+    if ((*it)->getOption().matches(Id))
+      return true;
+  
+  return false;
+}





More information about the cfe-commits mailing list