llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Jeewoong Kim (JeewoongKim) <details> <summary>Changes</summary> Use the `-o` argument to determine the dependency file name and default target for `-MD` in clang-cl. Fixes #<!-- -->189195 --- Full diff: https://github.com/llvm/llvm-project/pull/235578.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-2) - (modified) clang/test/Driver/cl-options.c (+5) ``````````diff diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 5a1c8531812bd3..08b16883d7fc8a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -873,7 +873,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, // If user provided -o, that is the dependency target, except // when we are only generating a dependency file. - Arg *OutputOpt = Args.getLastArg(options::OPT_o, options::OPT__SLASH_Fo); + Arg *OutputOpt = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o, + options::OPT__SLASH_Fo); if (OutputOpt && Output.getType() != types::TY_Dependencies) { DepTarget = OutputOpt->getValue(); } else { @@ -9250,7 +9251,7 @@ const char *Clang::getDependencyFileName(const ArgList &Args, const InputInfoList &Inputs) { // FIXME: Think about this more. - if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) { + if (Arg *OutputOpt = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o)) { SmallString<128> OutputFilename(OutputOpt->getValue()); llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d')); return Args.MakeArgString(OutputFilename); diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 536b93890ef71e..10e500aa16f57f 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -816,6 +816,11 @@ // CLANG-NOT: "--dependent-lib=libcmt" // CLANG-NOT: "-vectorize-slp" +// Validate that -o determines the default dependency file and target. +// RUN: %clang_cl /clang:-MD -c -o out.o -### -- %s 2>&1 | FileCheck --check-prefix=DEPFILE-O %s +// DEPFILE-O: "-dependency-file" "out.d" +// DEPFILE-O-SAME: "-MT" "out.o" + // Cover PR42501: clang-cl /clang: pass-through causes read-after-free with aliased options. // RUN: %clang_cl /clang:-save-temps /clang:-Wl,test1,test2 -### -- %s 2>&1 | FileCheck -check-prefix=SAVETEMPS %s // SAVETEMPS: "-save-temps=cwd" `````````` </details> https://github.com/llvm/llvm-project/pull/235578 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
