Skip to content

Commit 065f70a

Browse files
committedJun 9, 2015
clang-cl: Ignore the /o option when /P is specified.
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 llvm-svn: 239393
1 parent 0389d66 commit 065f70a

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed
 

‎clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,8 +1692,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
16921692
assert(AtTopLevel && isa<PreprocessJobAction>(JA));
16931693
StringRef BaseName = llvm::sys::path::filename(BaseInput);
16941694
StringRef NameArg;
1695-
if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi,
1696-
options::OPT__SLASH_o))
1695+
if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi))
16971696
NameArg = A->getValue();
16981697
return C.addResultFile(MakeCLOutputFilename(C.getArgs(), NameArg, BaseName,
16991698
types::TY_PP_C), &JA);

‎clang/test/Driver/cl-outputs.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,30 +249,23 @@
249249
// Fi2: "-E"
250250
// Fi2: "-o" "foo.x"
251251

252+
// To match MSVC behavior /o should be ignored for /P output.
253+
252254
// RUN: %clang_cl /P /ofoo -### -- %s 2>&1 | FileCheck -check-prefix=Fio1 %s
253255
// Fio1: "-E"
254-
// Fio1: "-o" "foo.i"
256+
// Fio1: "-o" "cl-outputs.i"
255257

256-
// RUN: %clang_cl /P /o foo -### -- %s 2>&1 | FileCheck -check-prefix=Fio2 %s
258+
// RUN: %clang_cl /P /o foo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio2 %s
257259
// Fio2: "-E"
258-
// Fio2: "-o" "foo.i"
259-
260-
// RUN: %clang_cl /P /ofoo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio3 %s
261-
// Fio3: "-E"
262-
// Fio3: "-o" "foo.x"
263-
264-
// RUN: %clang_cl /P /o foo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fio4 %s
265-
// Fio4: "-E"
266-
// Fio4: "-o" "foo.x"
267-
260+
// Fio2: "-o" "cl-outputs.i"
268261

269262
// RUN: %clang_cl /P /obar.x /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE1 %s
270263
// FioRACE1: "-E"
271264
// FioRACE1: "-o" "foo.x"
272265

273266
// RUN: %clang_cl /P /Fifoo.x /obar.x -### -- %s 2>&1 | FileCheck -check-prefix=FioRACE2 %s
274267
// FioRACE2: "-E"
275-
// FioRACE2: "-o" "bar.x"
268+
// FioRACE2: "-o" "foo.x"
276269

277270
// RUN: %clang_cl /c /GL -### -- %s 2>&1 | FileCheck -check-prefix=LTO-DEFAULT %s
278271
// LTO-DEFAULT: "-emit-llvm-bc"{{.*}}"-o" "cl-outputs.obj"

0 commit comments

Comments
 (0)
Please sign in to comment.