[cfe-commits] r91940 - in /cfe/trunk: include/clang/Driver/Options.td lib/Driver/Driver.cpp

Daniel Dunbar daniel at zuster.org
Tue Dec 22 15:19:32 PST 2009


Author: ddunbar
Date: Tue Dec 22 17:19:32 2009
New Revision: 91940

URL: http://llvm.org/viewvc/llvm-project?rev=91940&view=rev
Log:
Driver: When linking, don't warn about unused arguments which are obviously only
used during compilation.
 - There is no easy way to define this group properly, unfortunately, and maybe
   this is a losing strategy. For now this is unambiguous more friendly, though.

Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Driver.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Dec 22 17:19:32 2009
@@ -17,23 +17,27 @@
 /////////
 // Groups
 
-def I_Group               : OptionGroup<"<I group>">;
-def M_Group               : OptionGroup<"<M group>">;
+// Meta-group which defines
+def CompileOnly_Group     : OptionGroup<"<CompileOnly group>">;
+
+def I_Group               : OptionGroup<"<I group>">, Group<CompileOnly_Group>;
+def M_Group               : OptionGroup<"<M group>">, Group<CompileOnly_Group>;
 def T_Group               : OptionGroup<"<T group>">;
-def O_Group               : OptionGroup<"<O group>">;
-def W_Group               : OptionGroup<"<W group>">;
+def O_Group               : OptionGroup<"<O group>">, Group<CompileOnly_Group>;
+def W_Group               : OptionGroup<"<W group>">, Group<CompileOnly_Group>;
 def X_Group               : OptionGroup<"<X group>">;
 def a_Group               : OptionGroup<"<a group>">;
 def d_Group               : OptionGroup<"<d group>">;
-def f_Group               : OptionGroup<"<f group>">;
+def f_Group               : OptionGroup<"<f group>">, Group<CompileOnly_Group>;
 def g_Group               : OptionGroup<"<g group>">;
-def i_Group               : OptionGroup<"<i group>">;
+def i_Group               : OptionGroup<"<i group>">, Group<CompileOnly_Group>;
 def clang_i_Group         : OptionGroup<"<clang i group>">, Group<i_Group>;
-def m_Group               : OptionGroup<"<m group>">;
-def m_x86_Features_Group  : OptionGroup<"<m x86 features group>">;
+def m_Group               : OptionGroup<"<m group>">, Group<CompileOnly_Group>;
+def m_x86_Features_Group  : OptionGroup<"<m x86 features group>">, Group<m_Group>;
 def u_Group               : OptionGroup<"<u group>">;
 
-def pedantic_Group        : OptionGroup<"<pedantic group>">;
+def pedantic_Group        : OptionGroup<"<pedantic group>">,
+  Group<CompileOnly_Group>;
 
 // Temporary groups for clang options which we know we don't support,
 // but don't want to verbosely warn the user about.
@@ -116,7 +120,7 @@
 def B : JoinedOrSeparate<"-B">, Flags<[Unsupported]>;
 def CC : Flag<"-CC">;
 def C : Flag<"-C">;
-def D : JoinedOrSeparate<"-D">;
+def D : JoinedOrSeparate<"-D">, Group<CompileOnly_Group>;
 def E : Flag<"-E">, Flags<[DriverOption]>,
   HelpText<"Only run the preprocessor">;
 def F : JoinedOrSeparate<"-F">;
@@ -152,7 +156,7 @@
 def Tdata : JoinedOrSeparate<"-Tdata">, Group<T_Group>;
 def Ttext : JoinedOrSeparate<"-Ttext">, Group<T_Group>;
 def T : JoinedOrSeparate<"-T">, Group<T_Group>;
-def U : JoinedOrSeparate<"-U">;
+def U : JoinedOrSeparate<"-U">, Group<CompileOnly_Group>;
 def V : JoinedOrSeparate<"-V">, Flags<[DriverOption, Unsupported]>;
 def Wa_COMMA : CommaJoined<"-Wa,">,
   HelpText<"Pass the comma separated arguments in <arg> to the assembler">,

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Dec 22 17:19:32 2009
@@ -711,6 +711,11 @@
   // Add a link action if necessary.
   if (!LinkerInputs.empty())
     Actions.push_back(new LinkJobAction(LinkerInputs, types::TY_Image));
+
+  // If we are linking, claim any options which are obviously only used for
+  // compilation.
+  if (FinalPhase == phases::Link)
+    Args.ClaimAllArgs(options::OPT_CompileOnly_Group);
 }
 
 Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,





More information about the cfe-commits mailing list