]> granicus.if.org Git - clang/commitdiff
[Driver] Don't warn about unused inputs in config files
authorMartin Storsjo <martin@martin.st>
Fri, 4 May 2018 06:05:58 +0000 (06:05 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 4 May 2018 06:05:58 +0000 (06:05 +0000)
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

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

lib/Driver/Driver.cpp
test/Driver/Inputs/config-4.cfg
test/Driver/config-file.c

index 598a8f10a4b42aa288d85e9ea8c2d18cc96226d2..4680def33208e8ae844c2019b2a4571392e9d73d 100644 (file)
@@ -285,11 +285,12 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
 }
 
 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::TranslateInputArgs(const InputArgList &Args) const {
     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, DerivedArgList &Args,
     // 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();
 
index d8a022ae759223f8efde23ecb481b7fbb9c84d79..bbfc0c51f296b8142555826ee2be0bb500bc90f3 100644 (file)
@@ -1,2 +1,3 @@
 -L/usr/local/lib
--stdlib=libc++
\ No newline at end of file
+-lfoo
+-stdlib=libc++
index f9e6ce62cd58b1431f52f7e79e9430cd3b9350b1..04127d404f67f2a91206f0c69ca9b5d49eef1598 100644 (file)
@@ -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.