]> granicus.if.org Git - clang/commitdiff
clang-cl: Ignore the /o option when /P is specified.
authorGreg Bedwell <greg_bedwell@sn.scee.net>
Tue, 9 Jun 2015 10:24:06 +0000 (10:24 +0000)
committerGreg Bedwell <greg_bedwell@sn.scee.net>
Tue, 9 Jun 2015 10:24:06 +0000 (10:24 +0000)
This matches the cl.exe behavior (tested with 18.00.31101).  In order to
specify an output file for /P, use the /Fi option instead.

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

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

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

index 349c53dd757bfb3f3bb221d8f771d2c8837fb6e6..8cca1de0fb2b337f1b72e264ebf7710e2afdcb07 100644 (file)
@@ -1692,8 +1692,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
     assert(AtTopLevel && isa<PreprocessJobAction>(JA));
     StringRef BaseName = llvm::sys::path::filename(BaseInput);
     StringRef NameArg;
-    if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi,
-                                        options::OPT__SLASH_o))
+    if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi))
       NameArg = A->getValue();
     return C.addResultFile(MakeCLOutputFilename(C.getArgs(), NameArg, BaseName,
                                                 types::TY_PP_C), &JA);
index 9359968bdc8bb21589f80db19da2c20b44899a7c..b92c82687a9bb6e76a85a629e580aa2ce1256465 100644 (file)
 // Fi2: "-E"
 // Fi2: "-o" "foo.x"
 
+// To match MSVC behavior /o should be ignored for /P output.
+
 // RUN: %clang_cl /P /ofoo -### -- %s 2>&1 | FileCheck -check-prefix=Fio1 %s
 // Fio1: "-E"
-// Fio1: "-o" "foo.i"
+// Fio1: "-o" "cl-outputs.i"
 
-// RUN: %clang_cl /P /o foo -### -- %s 2>&1 | FileCheck -check-prefix=Fio2 %s
+// RUN: %clang_cl /P /o foo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio2 %s
 // Fio2: "-E"
-// Fio2: "-o" "foo.i"
-
-// RUN: %clang_cl /P /ofoo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio3 %s
-// Fio3: "-E"
-// Fio3: "-o" "foo.x"
-
-// RUN: %clang_cl /P /o foo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio4 %s
-// Fio4: "-E"
-// Fio4: "-o" "foo.x"
-
+// Fio2: "-o" "cl-outputs.i"
 
 // RUN: %clang_cl /P /obar.x /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE1 %s
 // FioRACE1: "-E"
 
 // RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE2 %s
 // FioRACE2: "-E"
-// FioRACE2: "-o" "bar.x"
+// FioRACE2: "-o" "foo.x"
 
 // RUN: %clang_cl /c /GL -### -- %s 2>&1 | FileCheck -check-prefix=LTO-DEFAULT %s
 // LTO-DEFAULT: "-emit-llvm-bc"{{.*}}"-o" "cl-outputs.obj"