r217699 - clang-cl: Don't treat linker input files differently when /TP or /TC is specified.

Ehsan Akhgari ehsan.akhgari at gmail.com
Fri Sep 12 11:15:10 PDT 2014


Author: ehsan
Date: Fri Sep 12 13:15:10 2014
New Revision: 217699

URL: http://llvm.org/viewvc/llvm-project?rev=217699&view=rev
Log:
clang-cl: Don't treat linker input files differently when /TP or /TC is specified.

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

Modified:
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/test/Driver/cl-inputs.c

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=217699&r1=217698&r2=217699&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Sep 12 13:15:10 2014
@@ -1076,8 +1076,17 @@ void Driver::BuildInputs(const ToolChain
         }
       } 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))

Modified: cfe/trunk/test/Driver/cl-inputs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-inputs.c?rev=217699&r1=217698&r2=217699&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-inputs.c (original)
+++ cfe/trunk/test/Driver/cl-inputs.c Fri Sep 12 13:15:10 2014
@@ -34,6 +34,14 @@
 // 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
 





More information about the cfe-commits mailing list