[cfe-commits] r68535 - in /cfe/trunk: include/clang/Driver/Option.h include/clang/Driver/Options.def lib/Driver/Driver.cpp lib/Driver/OptTable.cpp lib/Driver/Option.cpp

Daniel Dunbar daniel at zuster.org
Tue Apr 7 12:04:19 PDT 2009


Author: ddunbar
Date: Tue Apr  7 14:04:18 2009
New Revision: 68535

URL: http://llvm.org/viewvc/llvm-project?rev=68535&view=rev
Log:
Driver: Add 'q' flag for options which shouldn't be reported as unused.
 - <rdar://problem/6756295> warning about '-dynamic' argument unused
   during compilation seems incorrect

Modified:
    cfe/trunk/include/clang/Driver/Option.h
    cfe/trunk/include/clang/Driver/Options.def
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/OptTable.cpp
    cfe/trunk/lib/Driver/Option.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Tue Apr  7 14:04:18 2009
@@ -82,9 +82,12 @@
     /// Always render this option joined with its value.
     bool ForceJoinedRender : 1;    
 
-    /// This option is only for consumed by the driver.
+    /// This option is only consumed by the driver.
     bool DriverOption : 1;    
 
+    /// This option should not report argument unused errors.
+    bool NoArgumentUnused : 1;    
+
   protected:
     Option(OptionClass Kind, options::ID ID, const char *Name, 
            const OptionGroup *Group, const Option *Alias);
@@ -115,6 +118,9 @@
     bool isDriverOption() const { return DriverOption; }
     void setDriverOption(bool Value) { DriverOption = Value; }
 
+    bool hasNoArgumentUnused() const { return NoArgumentUnused; }
+    void setNoArgumentUnused(bool Value) { NoArgumentUnused = Value; }
+
     bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }
 
     /// getUnaliasedOption - Return the final option this option

Modified: cfe/trunk/include/clang/Driver/Options.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.def?rev=68535&r1=68534&r2=68535&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Options.def (original)
+++ cfe/trunk/include/clang/Driver/Options.def Tue Apr  7 14:04:18 2009
@@ -57,6 +57,11 @@
 //
 //  l: The option is a linker input.
 //
+//  q: Don't report argument unused warnings for this option; this is
+//     useful for options like -static or -dynamic which a user may
+//     always end up passing, even if the platform defaults to (or
+//     only supports) that option.
+//
 //  u: The option is unsupported, and the driver will reject command
 //     lines that use it.
 //
@@ -405,7 +410,7 @@
 OPTION("-dylinker_install_name", dylinker__install__name, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
 OPTION("-dylinker", dylinker, Flag, INVALID, INVALID, "", 0, 0, 0)
 OPTION("-dynamiclib", dynamiclib, Flag, INVALID, INVALID, "", 0, 0, 0)
-OPTION("-dynamic", dynamic, Flag, INVALID, INVALID, "", 0, 0, 0)
+OPTION("-dynamic", dynamic, Flag, INVALID, INVALID, "q", 0, 0, 0)
 OPTION("-d", d_Flag, Flag, d_Group, INVALID, "", 0, 0, 0)
 OPTION("-d", d_Joined, Joined, d_Group, INVALID, "", 0, 0, 0)
 OPTION("-emit-llvm", emit_llvm, Flag, INVALID, INVALID, "", 0, 
@@ -534,7 +539,7 @@
 OPTION("-m3dnow", m3dnow, Flag, m_Group, INVALID, "", 0, 0, 0)
 OPTION("-m64", m64, Flag, m_Group, INVALID, "", 0, 0, 0)
 OPTION("-mconstant-cfstrings", mconstant_cfstrings, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0)
-OPTION("-mdynamic-no-pic", mdynamic_no_pic, Joined, m_Group, INVALID, "", 0, 0, 0)
+OPTION("-mdynamic-no-pic", mdynamic_no_pic, Joined, m_Group, INVALID, "q", 0, 0, 0)
 OPTION("-mfix-and-continue", mfix_and_continue, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0)
 OPTION("-miphoneos-version-min=", miphoneos_version_min_EQ, Joined, m_Group, INVALID, "", 0, 0, 0)
 OPTION("-mkernel", mkernel, Flag, m_Group, INVALID, "", 0, 0, 0)
@@ -636,7 +641,7 @@
 OPTION("-specs=", specs_EQ, Joined, INVALID, INVALID, "", 0, 0, 0)
 OPTION("-specs", specs, Separate, INVALID, INVALID, "u", 0, 0, 0)
 OPTION("-static-libgcc", static_libgcc, Flag, INVALID, INVALID, "", 0, 0, 0)
-OPTION("-static", static, Flag, INVALID, INVALID, "", 0, 0, 0)
+OPTION("-static", static, Flag, INVALID, INVALID, "q", 0, 0, 0)
 OPTION("-std=", std_EQ, Joined, INVALID, INVALID, "", 0, 0, 0)
 OPTION("-sub_library", sub__library, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)
 OPTION("-sub_umbrella", sub__umbrella, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0)

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Apr  7 14:04:18 2009
@@ -802,7 +802,8 @@
 
   // If the user passed -Qunused-arguments or there were errors, don't
   // warn about any unused arguments.
-  if (Diags.getNumErrors() || C.getArgs().hasArg(options::OPT_Qunused_arguments))
+  if (Diags.getNumErrors() || 
+      C.getArgs().hasArg(options::OPT_Qunused_arguments))
     return;
 
   // Claim -### here.
@@ -816,6 +817,9 @@
     // Diagnostic, so that extra values, position, and so on could be
     // printed.
     if (!A->isClaimed()) {
+      if (A->getOption().hasNoArgumentUnused())
+        continue;
+
       // Suppress the warning automatically if this is just a flag,
       // and it is an instance of an argument we already claimed.
       const Option &Opt = A->getOption();

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

==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Tue Apr  7 14:04:18 2009
@@ -204,6 +204,7 @@
     case 'd': Opt->setDriverOption(true); break;
     case 'i': Opt->setNoOptAsInput(true); break;
     case 'l': Opt->setLinkerInput(true); break;
+    case 'q': Opt->setNoArgumentUnused(true); break;
     case 'u': Opt->setUnsupported(true); break;
     }
   }

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

==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Tue Apr  7 14:04:18 2009
@@ -21,7 +21,7 @@
   : Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
     Unsupported(false), LinkerInput(false), NoOptAsInput(false),
     ForceSeparateRender(false), ForceJoinedRender(false),
-    DriverOption(false)
+    DriverOption(false), NoArgumentUnused(false)
 {
 
   // Multi-level aliases are not supported, and alias options cannot





More information about the cfe-commits mailing list