r331504 - [Driver] Don't warn about unused inputs in config files

Martin Storsjo via cfe-commits cfe-commits at lists.llvm.org
Thu May 3 23:05:58 PDT 2018


Author: mstorsjo
Date: Thu May  3 23:05:58 2018
New Revision: 331504

URL: http://llvm.org/viewvc/llvm-project?rev=331504&view=rev
Log:
[Driver] Don't warn about unused inputs in config files

This avoids warnings about unused linker parameters, just like
other flags are ignored if they're from config files.

Differential Revision: https://reviews.llvm.org/D46286

Modified:
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/test/Driver/Inputs/config-4.cfg
    cfe/trunk/test/Driver/config-file.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=331504&r1=331503&r2=331504&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu May  3 23:05:58 2018
@@ -285,11 +285,12 @@ phases::ID Driver::getFinalPhase(const D
 }
 
 static Arg *MakeInputArg(DerivedArgList &Args, OptTable &Opts,
-                         StringRef Value) {
+                         StringRef Value, bool Claim = true) {
   Arg *A = new Arg(Opts.getOption(options::OPT_INPUT), Value,
                    Args.getBaseArgs().MakeIndex(Value), Value.data());
   Args.AddSynthesizedArg(A);
-  A->claim();
+  if (Claim)
+    A->claim();
   return A;
 }
 
@@ -357,7 +358,7 @@ DerivedArgList *Driver::TranslateInputAr
     if (A->getOption().matches(options::OPT__DASH_DASH)) {
       A->claim();
       for (StringRef Val : A->getValues())
-        DAL->append(MakeInputArg(*DAL, *Opts, Val));
+        DAL->append(MakeInputArg(*DAL, *Opts, Val, false));
       continue;
     }
 
@@ -2906,6 +2907,9 @@ void Driver::BuildActions(Compilation &C
     // this compilation, warn the user about it.
     phases::ID InitialPhase = PL[0];
     if (InitialPhase > FinalPhase) {
+      if (InputArg->isClaimed())
+        continue;
+
       // Claim here to avoid the more general unused warning.
       InputArg->claim();
 

Modified: cfe/trunk/test/Driver/Inputs/config-4.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/config-4.cfg?rev=331504&r1=331503&r2=331504&view=diff
==============================================================================
--- cfe/trunk/test/Driver/Inputs/config-4.cfg (original)
+++ cfe/trunk/test/Driver/Inputs/config-4.cfg Thu May  3 23:05:58 2018
@@ -1,2 +1,3 @@
 -L/usr/local/lib
--stdlib=libc++
\ No newline at end of file
+-lfoo
+-stdlib=libc++

Modified: cfe/trunk/test/Driver/config-file.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/config-file.c?rev=331504&r1=331503&r2=331504&view=diff
==============================================================================
--- cfe/trunk/test/Driver/config-file.c (original)
+++ cfe/trunk/test/Driver/config-file.c Thu May  3 23:05:58 2018
@@ -63,6 +63,7 @@
 //
 // RUN: %clang --config %S/Inputs/config-4.cfg -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-UNUSED
 // CHECK-UNUSED-NOT: argument unused during compilation:
+// CHECK-UNUSED-NOT: 'linker' input unused
 
 
 //--- User directory is searched first.




More information about the cfe-commits mailing list