https://github.com/sharadhr updated https://github.com/llvm/llvm-project/pull/121046
>From 3a84b5906330c4f6308e10c50381f06956c27e2d Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman <r.shar...@outlook.sg> Date: Tue, 24 Dec 2024 09:32:21 +0000 Subject: [PATCH 1/5] Accept /Fo and -Fo in `-fmodule-output` when running under CL mode --- clang/lib/Driver/Driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 4d9492ea08f647..67b5e7268051ae 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6099,7 +6099,7 @@ 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)) + if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON)) return C.addResultFile(FinalOutput->getValue(), &JA); } >From 1a471fe6ef2549c53b393ac407756f4a4bbc7363 Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman <r.shar...@outlook.sg> Date: Sun, 5 Jan 2025 14:09:24 +0000 Subject: [PATCH 2/5] Use `IsCLMode` to guard cl-style output argument presence --- clang/lib/Driver/Driver.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 67b5e7268051ae..41c30899807c52 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6099,8 +6099,15 @@ 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, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON)) + Arg *FinalOutput = + IsCLMode() + ? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo, + options::OPT__SLASH_Fo_COLON) + : C.getArgs().getLastArg(options::OPT_o); + + if (FinalOutput != nullptr) { return C.addResultFile(FinalOutput->getValue(), &JA); + } } // For /P, preprocess to file named after BaseInput. >From fe69cf4b4de805b67b877e7b30165e32a986dedc Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman <r.shar...@outlook.sg> Date: Thu, 9 Jan 2025 19:20:30 +0000 Subject: [PATCH 3/5] Test for `/Yc` and `/Fp` under CL mode --- clang/lib/Driver/Driver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 41c30899807c52..32d87a4eaa59ca 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6100,7 +6100,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, // Output to a user requested destination? if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) { Arg *FinalOutput = - IsCLMode() + // CL and not generating a PCH: test for Fo, Fp, and Yc + IsCLMode() && !(C.getArgs().hasArg(options::OPT__SLASH_Yc) && + C.getArgs().hasArg(options::OPT__SLASH_Fp)) ? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON) : C.getArgs().getLastArg(options::OPT_o); >From d7b7e93fb04fc624e7ce3758bd385bdea1a388a9 Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman <r.shar...@outlook.sg> Date: Sun, 12 Jan 2025 21:44:33 +0000 Subject: [PATCH 4/5] Account for /Yc when generating PCH --- clang/lib/Driver/Driver.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 32d87a4eaa59ca..a59f7108c07602 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6099,11 +6099,11 @@ 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)) { + // CL and not building a PCH. Not sure why the GNU-style driver doesn't need + // this. May need to rethink. Arg *FinalOutput = - // CL and not generating a PCH: test for Fo, Fp, and Yc - IsCLMode() && !(C.getArgs().hasArg(options::OPT__SLASH_Yc) && - C.getArgs().hasArg(options::OPT__SLASH_Fp)) - ? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo, + IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) + ? C.getArgs().getLastArg(options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON) : C.getArgs().getLastArg(options::OPT_o); >From a8390721b50a1dbbdf6ec99e9468554c4fcaabf6 Mon Sep 17 00:00:00 2001 From: Sharadh Rajaraman <r.shar...@outlook.sg> Date: Sun, 12 Jan 2025 23:51:16 +0000 Subject: [PATCH 5/5] Fix PCH and cl-output tests --- clang/lib/Driver/Driver.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index a59f7108c07602..ceb8c615e6dfb8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6099,15 +6099,14 @@ 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)) { - // CL and not building a PCH. Not sure why the GNU-style driver doesn't need - // this. May need to rethink. - Arg *FinalOutput = - IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc) - ? C.getArgs().getLastArg(options::OPT__SLASH_Fo, - options::OPT__SLASH_Fo_COLON) - : C.getArgs().getLastArg(options::OPT_o); - - if (FinalOutput != nullptr) { + Arg *FinalOutput = IsCLMode() + && !C.getArgs().hasArg(options::OPT__SLASH_Yc) && + (isa<PreprocessJobAction>(JA) + || isa<PrecompileJobAction>(JA)) + ? C.getArgs().getLastArg(options::OPT__SLASH_Fo, + options::OPT__SLASH_Fo_COLON) + : C.getArgs().getLastArg(options::OPT_o); + if (FinalOutput) { return C.addResultFile(FinalOutput->getValue(), &JA); } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits