]> granicus.if.org Git - clang/commitdiff
Driver: Add ArgList::hasArg, for testing for the presence of an
authorDaniel Dunbar <daniel@zuster.org>
Thu, 12 Mar 2009 01:36:44 +0000 (01:36 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 12 Mar 2009 01:36:44 +0000 (01:36 +0000)
argument matching some Option::ID.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66758 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c4f3bbc1a458f010d02e7c84a5a7536dbac25438..4131ff4d168f91434e47746740788aa90c578172 100644 (file)
@@ -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 @@ namespace driver {
 
     /// 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
index a45e9d67b2161ec5d37ccba5286f8b58b2e6b765..6a056074b7c08be05d5278a24305e2c880c124b0 100644 (file)
@@ -29,3 +29,14 @@ void ArgList::append(Arg *A) {
 
   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;
+}