From: Martin Storsjo Date: Fri, 4 May 2018 06:05:58 +0000 (+0000) Subject: [Driver] Don't warn about unused inputs in config files X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bd865cff3f42b0425d64269fcc6de919f7bb2d5;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331504 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 598a8f10a4..4680def332 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -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(); diff --git a/test/Driver/Inputs/config-4.cfg b/test/Driver/Inputs/config-4.cfg index d8a022ae75..bbfc0c51f2 100644 --- a/test/Driver/Inputs/config-4.cfg +++ b/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++ diff --git a/test/Driver/config-file.c b/test/Driver/config-file.c index f9e6ce62cd..04127d404f 100644 --- a/test/Driver/config-file.c +++ b/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.