Index: include/clang/Driver/CLCompatOptions.td =================================================================== --- include/clang/Driver/CLCompatOptions.td +++ include/clang/Driver/CLCompatOptions.td @@ -154,6 +154,9 @@ def _SLASH_Fe : CLJoined<"Fe">, HelpText<"Set output executable file or directory (ends in / or \\)">, MetaVarName<"">; +def _SLASH_Fi : CLCompileJoined<"Fi">, + HelpText<"Set preprocess output file name">, + MetaVarName<"">; def _SLASH_Fo : CLCompileJoined<"Fo">, HelpText<"Set output object file, or directory (ends in / or \\)">, MetaVarName<"">; @@ -212,7 +215,6 @@ def _SLASH_FC : CLFlag<"FC">; def _SLASH_F : CLFlag<"F">; def _SLASH_Fd : CLJoined<"Fd">; -def _SLASH_Fi : CLJoined<"Fi">; def _SLASH_Fm : CLJoined<"Fm">; def _SLASH_fp : CLJoined<"fp">; def _SLASH_Fp : CLJoined<"Fp">; Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1615,7 +1615,10 @@ if (C.getArgs().hasArg(options::OPT__SLASH_P)) { assert(AtTopLevel && isa(JA)); StringRef BaseName = llvm::sys::path::filename(BaseInput); - return C.addResultFile(MakeCLOutputFilename(C.getArgs(), "", BaseName, + StringRef Val; + if (C.getArgs().hasArg(options::OPT__SLASH_Fi)) + Val = C.getArgs().getLastArg(options::OPT__SLASH_Fi)->getValue(); + return C.addResultFile(MakeCLOutputFilename(C.getArgs(), Val, BaseName, types::TY_PP_C), &JA); } Index: test/Driver/cl-options.c =================================================================== --- test/Driver/cl-options.c +++ test/Driver/cl-options.c @@ -30,6 +30,14 @@ // EP: "-P" // EP: "-o" "-" +// RUN: %clang_cl /P /Fifoo -### -- %s 2>&1 | FileCheck -check-prefix=Fi1 %s +// Fi1: "-E" +// Fi1: "-o" "foo.i" + +// RUN: %clang_cl /P /Fifoo.x -### -- %s 2>&1 | FileCheck -check-prefix=Fi2 %s +// Fi2: "-E" +// Fi2: "-o" "foo.x" + // RTTI is on by default; just check that we don't error. // RUN: %clang_cl /Zs /GR -- %s 2>&1