[clang] [clang-cl] Accept `cl`-style output arguments (`/Fo`, `-Fo`) for `--fmodule-output` (PR #121046)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 05:51:10 PST 2025
================
@@ -6097,10 +6097,29 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
}
llvm::PrettyStackTraceString CrashInfo("Computing output path");
+
// Output to a user requested destination?
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
- if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+ bool IsCLNonPCH =
+ IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
+ (isa<PreprocessJobAction>(JA) || isa<PrecompileJobAction>(JA));
+ bool HasAnyOutputArg = C.getArgs().hasArg(
+ options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
+
+ Arg *FinalOutput = nullptr;
+ if (IsCLNonPCH && HasAnyOutputArg) {
+ FinalOutput = C.getArgs().getLastArg(
+ options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON);
+ } else if (IsCLNonPCH) {
+ FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo,
+ options::OPT__SLASH_Fo_COLON);
+ } else {
+ FinalOutput = C.getArgs().getLastArg(options::OPT_o);
+ }
----------------
zmodem wrote:
I'm having trouble following the logic here. Can you add a comment explaining what's going on? I.e. when is `-o` and/or `/Fo` supposed to be considered?
https://github.com/llvm/llvm-project/pull/121046
More information about the cfe-commits
mailing list