]> granicus.if.org Git - clang/commitdiff
Driver: Add 'q' flag for options which shouldn't be reported as unused.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 7 Apr 2009 19:04:18 +0000 (19:04 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 7 Apr 2009 19:04:18 +0000 (19:04 +0000)
 - <rdar://problem/6756295> warning about '-dynamic' argument unused
   during compilation seems incorrect

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

include/clang/Driver/Option.h
include/clang/Driver/Options.def
lib/Driver/Driver.cpp
lib/Driver/OptTable.cpp
lib/Driver/Option.cpp

index c7b6d0e08c1085061c4474dba97840ae886a12ca..c59faef897aee7c4707be3738691c4241eb3d3b9 100644 (file)
@@ -82,9 +82,12 @@ namespace driver {
     /// 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 @@ namespace driver {
     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
index b8591815b4f6c0b9ce51fcc6d85ef3573131c055..7e77a1a51cbdca3c831658a0602826e0b9c699ab 100644 (file)
 //
 //  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("-dylib_file", dylib__file, Separate, INVALID, INVALID, "", 0, 0, 0)
 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("-m3dnowa", m3dnowa, Flag, m_Group, INVALID, "", 0, 0, 0)
 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("-single_module", single__module, Flag, INVALID, INVALID, "", 0, 0, 0)
 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)
index 68ff8bc8b0c444484bf96b9ec57607df257f15f6..f9a82ff78d437e0de429b768c9087ed594fabe9f 100644 (file)
@@ -802,7 +802,8 @@ void Driver::BuildJobs(Compilation &C) const {
 
   // 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 @@ void Driver::BuildJobs(Compilation &C) const {
     // 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();
index cbbeea1974cbcf0925db6062f0384cb150ced244..7ea6a8b0d9f49015a4225853c74d091427bd5218 100644 (file)
@@ -204,6 +204,7 @@ Option *OptTable::constructOption(options::ID id) const {
     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;
     }
   }
index 624854815d64b9b080b10caa918d3fa23d32d6ae..cad2bbf2b75eaacf44b904a5a4a395b134747346 100644 (file)
@@ -21,7 +21,7 @@ Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name,
   : 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