================ @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits