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

Daniel Dunbar daniel at zuster.org
Wed Nov 25 03:53:23 PST 2009


Author: ddunbar
Date: Wed Nov 25 05:53:23 2009
New Revision: 89861

URL: http://llvm.org/viewvc/llvm-project?rev=89861&view=rev
Log:
What the FIXMEs want, the FIXMEs shall have.

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

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

==============================================================================
--- cfe/trunk/include/clang/Driver/ArgList.h (original)
+++ cfe/trunk/include/clang/Driver/ArgList.h Wed Nov 25 05:53:23 2009
@@ -62,6 +62,7 @@
       SkipToNextArg();
     }
 
+    operator const Arg*() { return *Current; }
     reference operator*() const { return *Current; }
     pointer operator->() const { return *Current; }
 

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Nov 25 05:53:23 2009
@@ -965,10 +965,9 @@
       if (isa<FlagOption>(Opt)) {
         bool DuplicateClaimed = false;
 
-        // FIXME: Use iterator.
-        for (ArgList::const_iterator it = C.getArgs().begin(),
-               ie = C.getArgs().end(); it != ie; ++it) {
-          if ((*it)->isClaimed() && (*it)->getOption().matches(&Opt)) {
+        for (arg_iterator it = C.getArgs().filtered_begin(&Opt),
+               ie = C.getArgs().filtered_end(); it != ie; ++it) {
+          if ((*it)->isClaimed()) {
             DuplicateClaimed = true;
             break;
           }

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

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Nov 25 05:53:23 2009
@@ -130,13 +130,9 @@
   // wonky, but we include looking for .gch so we can support seamless
   // replacement into a build system already set up to be generating
   // .gch files.
-  //
-  // FIXME: Use iterator.
-  for (ArgList::const_iterator
-         it = Args.begin(), ie = Args.end(); it != ie; ++it) {
-    const Arg *A = *it;
-    if (!A->getOption().matches(options::OPT_clang_i_Group))
-      continue;
+  for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group),
+         ie = Args.filtered_end(); it != ie; ++it) {
+    const Arg *A = it;
 
     if (A->getOption().matches(options::OPT_include)) {
       // Use PCH if the user requested it, except for C++ (for now).
@@ -484,25 +480,21 @@
     CmdArgs.push_back(CPUName);
   }
 
-  // FIXME: Use iterator.
-  for (ArgList::const_iterator
-         it = Args.begin(), ie = Args.end(); it != ie; ++it) {
-    const Arg *A = *it;
-    if (A->getOption().matches(options::OPT_m_x86_Features_Group)) {
-      llvm::StringRef Name = A->getOption().getName();
-
-      // Skip over "-m".
-      assert(Name.startswith("-m") && "Invalid feature name.");
-      Name = Name.substr(2);
-
-      bool IsNegative = Name.startswith("no-");
-      if (IsNegative)
-        Name = Name.substr(3);
+  for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group),
+         ie = Args.filtered_end(); it != ie; ++it) {
+    llvm::StringRef Name = it->getOption().getName();
+    it->claim();
+
+    // Skip over "-m".
+    assert(Name.startswith("-m") && "Invalid feature name.");
+    Name = Name.substr(2);
+
+    bool IsNegative = Name.startswith("no-");
+    if (IsNegative)
+      Name = Name.substr(3);
 
-      A->claim();
-      CmdArgs.push_back("-target-feature");
-      CmdArgs.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
-    }
+    CmdArgs.push_back("-target-feature");
+    CmdArgs.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
   }
 }
 
@@ -1089,15 +1081,10 @@
 
   // Explicitly warn that these options are unsupported, even though
   // we are allowing compilation to continue.
-  // FIXME: Use iterator.
-  for (ArgList::const_iterator
-         it = Args.begin(), ie = Args.end(); it != ie; ++it) {
-    const Arg *A = *it;
-    if (A->getOption().matches(options::OPT_pg)) {
-      A->claim();
-      D.Diag(clang::diag::warn_drv_clang_unsupported)
-        << A->getAsString(Args);
-    }
+  for (arg_iterator it = Args.filtered_begin(options::OPT_pg),
+         ie = Args.filtered_end(); it != ie; ++it) {
+    it->claim();
+    D.Diag(clang::diag::warn_drv_clang_unsupported) << it->getAsString(Args);
   }
 
   // Claim some arguments which clang supports automatically.
@@ -1110,15 +1097,8 @@
 
   // Claim some arguments which clang doesn't support, but we don't
   // care to warn the user about.
-
-  // FIXME: Use iterator.
-  for (ArgList::const_iterator
-         it = Args.begin(), ie = Args.end(); it != ie; ++it) {
-    const Arg *A = *it;
-    if (A->getOption().matches(options::OPT_clang_ignored_f_Group) ||
-        A->getOption().matches(options::OPT_clang_ignored_m_Group))
-      A->claim();
-  }
+  Args.ClaimAllArgs(options::OPT_clang_ignored_f_Group);
+  Args.ClaimAllArgs(options::OPT_clang_ignored_m_Group);
 }
 
 void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
@@ -1391,18 +1371,13 @@
     // used to inhibit the default -fno-builtin-str{cat,cpy}.
     //
     // FIXME: Should we grow a better way to deal with "removing" args?
-    //
-    // FIXME: Use iterator.
-    for (ArgList::const_iterator it = Args.begin(),
-           ie = Args.end(); it != ie; ++it) {
-      const Arg *A = *it;
-      if (A->getOption().matches(options::OPT_f_Group) ||
-          A->getOption().matches(options::OPT_fsyntax_only)) {
-        if (!A->getOption().matches(options::OPT_fbuiltin_strcat) &&
-            !A->getOption().matches(options::OPT_fbuiltin_strcpy)) {
-          A->claim();
-          A->render(Args, CmdArgs);
-        }
+    for (arg_iterator it = Args.filtered_begin(options::OPT_f_Group,
+                                               options::OPT_fsyntax_only),
+           ie = Args.filtered_end(); it != ie; ++it) {
+      if (!it->getOption().matches(options::OPT_fbuiltin_strcat) &&
+          !it->getOption().matches(options::OPT_fbuiltin_strcpy)) {
+        it->claim();
+        it->render(Args, CmdArgs);
       }
     }
   } else





More information about the cfe-commits mailing list