Skip to content

Commit b6bda7b

Browse files
committed
Accept /Fo and -Fo in -fmodule-output when running under CL mode
1 parent 4f4e2ab commit b6bda7b

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
@@ -6097,10 +6097,29 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
60976097
}
60986098

60996099
llvm::PrettyStackTraceString CrashInfo("Computing output path");
6100+
61006101
// Output to a user requested destination?
61016102
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
6102-
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
6103+
bool IsCLNonPCH =
6104+
IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
6105+
(isa<PreprocessJobAction>(JA) || isa<PrecompileJobAction>(JA));
6106+
bool HasAnyOutputArg = C.getArgs().hasArg(
6107+
options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
6108+
6109+
Arg *FinalOutput = nullptr;
6110+
if (IsCLNonPCH && HasAnyOutputArg) {
6111+
FinalOutput = C.getArgs().getLastArg(
6112+
options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
6113+
} else if (IsCLNonPCH) {
6114+
FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo,
6115+
options::OPT__SLASH_Fo_COLON);
6116+
} else {
6117+
FinalOutput = C.getArgs().getLastArg(options::OPT_o);
6118+
}
6119+
6120+
if (FinalOutput) {
61036121
return C.addResultFile(FinalOutput->getValue(), &JA);
6122+
}
61046123
}
61056124

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

0 commit comments

Comments
 (0)