Skip to content

Commit d6c2b9b

Browse files
committed
Accept /Fo and -Fo in -fmodule-output when running under CL mode
1 parent 4863d1f commit d6c2b9b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6204,10 +6204,29 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
62046204
}
62056205

62066206
llvm::PrettyStackTraceString CrashInfo("Computing output path");
6207+
62076208
// Output to a user requested destination?
62086209
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
6209-
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
6210+
bool IsCLNonPCH =
6211+
IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
6212+
(isa<PreprocessJobAction>(JA) || isa<PrecompileJobAction>(JA));
6213+
bool HasAnyOutputArg = C.getArgs().hasArg(
6214+
options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
6215+
6216+
Arg *FinalOutput = nullptr;
6217+
if (IsCLNonPCH && HasAnyOutputArg) {
6218+
FinalOutput = C.getArgs().getLastArg(
6219+
options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
6220+
} else if (IsCLNonPCH) {
6221+
FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo,
6222+
options::OPT__SLASH_Fo_COLON);
6223+
} else {
6224+
FinalOutput = C.getArgs().getLastArg(options::OPT_o);
6225+
}
6226+
6227+
if (FinalOutput) {
62106228
return C.addResultFile(FinalOutput->getValue(), &JA);
6229+
}
62116230
}
62126231

62136232
// For /P, preprocess to file named after BaseInput.

0 commit comments

Comments
 (0)