]> granicus.if.org Git - clang/commitdiff
clang-cl: Don't treat linker input files differently when /TP or /TC is specified.
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 12 Sep 2014 18:15:10 +0000 (18:15 +0000)
committerEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 12 Sep 2014 18:15:10 +0000 (18:15 +0000)
Summary: This fixes http://llvm.org/PR20923.

Test Plan: This patch includes an automated test.

Reviewers: hansw

Subscribers: cfe-commits

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

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

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

index 04d4d44d2ea19bcc0a84553f5b0cae138065f08f..e448eb153a8fee2bed82548a6317d3e079c3633d 100644 (file)
@@ -1076,8 +1076,17 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
         }
       } else {
         assert(InputTypeArg && "InputType set w/o InputTypeArg");
-        InputTypeArg->claim();
-        Ty = InputType;
+        if (!InputTypeArg->getOption().matches(options::OPT_x)) {
+          // If emulating cl.exe, make sure that /TC and /TP don't affect input
+          // object files.
+          const char *Ext = strrchr(Value, '.');
+          if (Ext && TC.LookupTypeForExtension(Ext + 1) == types::TY_Object)
+            Ty = types::TY_Object;
+        }
+        if (Ty == types::TY_INVALID) {
+          Ty = InputType;
+          InputTypeArg->claim();
+        }
       }
 
       if (DiagnoseInputExistence(*this, Args, Value))
index 029aeadaec42b78ba12a245cbebdc9e92aca5e94..c0d4778d76bcbdbb37ba780f00e834176dacc907 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
+// TPlib: warning: cl-test.lib: 'linker' input unused
+// 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
+// TClib: warning: cl-test.lib: 'linker' input unused
+// TClib-NOT: cl-test.lib
+
 // RUN: not %clang_cl - 2>&1 | FileCheck -check-prefix=STDIN %s
 // STDIN: error: use /Tc or /Tp