]> granicus.if.org Git - clang/commitdiff
clang-cl: Warn when a /TC or /TP argument is unused
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 12 Sep 2014 21:44:24 +0000 (21:44 +0000)
committerEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 12 Sep 2014 21:44:24 +0000 (21:44 +0000)
Test Plan: The patch includes a test case.

Reviewers: hansw

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D5338

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

lib/Driver/Driver.cpp
test/Driver/cl-inputs.c

index e448eb153a8fee2bed82548a6317d3e079c3633d..c4d983fa2dad9e77e3306cd67010ea9276ea7ff6 100644 (file)
@@ -987,8 +987,8 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
   Arg *InputTypeArg = nullptr;
 
   // The last /TC or /TP option sets the input type to C or C++ globally.
-  if (Arg *TCTP = Args.getLastArg(options::OPT__SLASH_TC,
-                                  options::OPT__SLASH_TP)) {
+  if (Arg *TCTP = Args.getLastArgNoClaim(options::OPT__SLASH_TC,
+                                         options::OPT__SLASH_TP)) {
     InputTypeArg = TCTP;
     InputType = TCTP->getOption().matches(options::OPT__SLASH_TC)
         ? types::TY_C : types::TY_CXX;
index c0d4778d76bcbdbb37ba780f00e834176dacc907..b0265df52f05214ad08a22689666eed1efc567d5 100644 (file)
 // WARN: note: The last /TC or /TP option takes precedence over earlier instances
 // WARN-NOT: note
 
-// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TP cl-test.lib %s -### 2>&1 | FileCheck -check-prefix=TPlib %s
+// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s
 // TPlib: warning: cl-test.lib: 'linker' input unused
+// TPlib: warning: argument unused during compilation: '/TP'
 // TPlib-NOT: cl-test.lib
 
-// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TC cl-test.lib %s -### 2>&1 | FileCheck -check-prefix=TClib %s
+// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TC cl-test.lib -### 2>&1 | FileCheck -check-prefix=TClib %s
 // TClib: warning: cl-test.lib: 'linker' input unused
+// TClib: warning: argument unused during compilation: '/TC'
 // TClib-NOT: cl-test.lib
 
 // RUN: not %clang_cl - 2>&1 | FileCheck -check-prefix=STDIN %s