[PATCH] D46286: [Driver] Don't warn about unused inputs in config files

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 01:50:55 PDT 2018


mstorsjo updated this revision to Diff 144839.
mstorsjo added a comment.

In order not to break test/Driver/cl-pch.cpp (I hadn't run the full testsuite for this change before submitting the patch), I had to do another tweak, in order not to claim any input argument after `--`. Does it still sound ok to you @sepavloff?


https://reviews.llvm.org/D46286

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


Index: test/Driver/config-file.c
===================================================================
--- test/Driver/config-file.c
+++ test/Driver/config-file.c
@@ -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.
Index: test/Driver/Inputs/config-4.cfg
===================================================================
--- test/Driver/Inputs/config-4.cfg
+++ test/Driver/Inputs/config-4.cfg
@@ -1,2 +1,3 @@
 -L/usr/local/lib
--stdlib=libc++
\ No newline at end of file
+-lfoo
+-stdlib=libc++
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -285,11 +285,12 @@
 }
 
 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 @@
     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 @@
     // 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();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46286.144839.patch
Type: text/x-patch
Size: 1883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180502/f479da1c/attachment.bin>


More information about the cfe-commits mailing list