[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-24 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea closed https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-24 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea updated https://github.com/llvm/llvm-project/pull/89950 >From 13c411018e491fc2be4f4118a56f9b8cf2e5b76f Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 17 Apr 2024 16:28:21 -0400 Subject: [PATCH 1/5] [clang-scan-deps] Expand response files before the

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-24 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-24 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 deleted https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-24 Thread Jan Svoboda via cfe-commits
@@ -0,0 +1,36 @@ +// Check that the scanner can adjust arguments by reading .rsp files in advance. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json jansvoboda11 wrote: Ok, that makes sense, thanks!

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-24 Thread Jan Svoboda via cfe-commits
@@ -86,6 +86,8 @@ static bool DeprecatedDriverCommand; static ResourceDirRecipeKind ResourceDirRecipe; static bool Verbose; static bool PrintTiming; +static llvm::BumpPtrAllocator Alloc; +static llvm::StringSaver Saver{Alloc}; jansvoboda11 wrote: Why do these

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-22 Thread Alexandre Ganea via cfe-commits
aganea wrote: @jansvoboda11 Do you see any further changes for this PR? Can I land it? https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-05-06 Thread Jan Svoboda via cfe-commits
@@ -0,0 +1,36 @@ +// Check that the scanner can adjust arguments by reading .rsp files in advance. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json +// RUN: echo /Fo%t/tu.obj >> %t/args_nested.rsp

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-29 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-29 Thread Alexandre Ganea via cfe-commits
@@ -792,10 +792,15 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { llvm::cl::PrintOptionValues(); + // Expand response files in advance, so that we can "see" all the arguments + // when adjusting below. + auto ResponseExpander =

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-29 Thread Alexandre Ganea via cfe-commits
@@ -0,0 +1,36 @@ +// Check that the scanner can adjust arguments by reading .rsp files in advance. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json +// RUN: echo /Fo%t/tu.obj >> %t/args_nested.rsp

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-29 Thread Alexandre Ganea via cfe-commits
@@ -0,0 +1,36 @@ +// Check that the scanner can adjust arguments by reading .rsp files in advance. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json aganea wrote: As suggested. We're taking a

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-29 Thread Alexandre Ganea via cfe-commits
@@ -1069,7 +1069,7 @@ void Clang::AddPreprocessingOptions(Compilation , const JobAction , // 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); +

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-29 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea updated https://github.com/llvm/llvm-project/pull/89950 >From f2340c98c95e0d72516fc240ff268fead9f15391 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 17 Apr 2024 16:28:21 -0400 Subject: [PATCH 1/5] [clang-scan-deps] Expand response files before the

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-25 Thread Jan Svoboda via cfe-commits
@@ -792,10 +792,15 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { llvm::cl::PrintOptionValues(); + // Expand response files in advance, so that we can "see" all the arguments + // when adjusting below. + auto ResponseExpander =

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-25 Thread Jan Svoboda via cfe-commits
@@ -0,0 +1,36 @@ +// Check that the scanner can adjust arguments by reading .rsp files in advance. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json +// RUN: echo /Fo%t/tu.obj >> %t/args_nested.rsp

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-25 Thread Jan Svoboda via cfe-commits
https://github.com/jansvoboda11 edited https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-25 Thread Jan Svoboda via cfe-commits
@@ -0,0 +1,36 @@ +// Check that the scanner can adjust arguments by reading .rsp files in advance. + +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json jansvoboda11 wrote: You can now do this:

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-25 Thread Jan Svoboda via cfe-commits
@@ -1069,7 +1069,7 @@ void Clang::AddPreprocessingOptions(Compilation , const JobAction , // 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); +

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Alexandre Ganea via cfe-commits
aganea wrote: @jansvoboda11 PTAL. I've added handling of `/Fo` in the driver, and that solves my case without the .rsp expansion in `ClangScanDeps.cpp`. However if we pass `/E` to command-lines in the CDB, that change alone doesn't work anymore. This is because `Driver::GetNamedOutputPath()`

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea updated https://github.com/llvm/llvm-project/pull/89950 >From f2340c98c95e0d72516fc240ff268fead9f15391 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 17 Apr 2024 16:28:21 -0400 Subject: [PATCH 1/3] [clang-scan-deps] Expand response files before the

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea updated https://github.com/llvm/llvm-project/pull/89950 >From f2340c98c95e0d72516fc240ff268fead9f15391 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea Date: Wed, 17 Apr 2024 16:28:21 -0400 Subject: [PATCH 1/2] [clang-scan-deps] Expand response files before the

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: Hmm, that driver code is only executed if the dependency file was requested on the Clang command line, though. `clang-scan-deps` should be able to generate the dependency file even if the original command line doesn't have `-MD` and friends. That's why we call

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Alexandre Ganea via cfe-commits
aganea wrote: The reason of this `/Fo` output path fiddling code is this: https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Clang.cpp#L1072-L1082 It's because that highlighted code doesn't handle the clang-cl case, it doesn't consider `/Fo`. Probably because most

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: > Maybe the issue is that the DependencyOptions we pass have no target set, > since the original command line doesn't have -MD (or something like that)? No, even then we should deduce the output path:

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Jan Svoboda via cfe-commits
jansvoboda11 wrote: This change makes sense to me, but I forget what's the purpose of the whole output path deducing code. Even for `clang-cl` command lines we should go through the driver and get a `CompilerInvocation` that will have the output file set (if the action does produce an output

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Alexandre Ganea via cfe-commits
aganea wrote: This is missing a test, I will add one. https://github.com/llvm/llvm-project/pull/89950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Alexandre Ganea (aganea) Changes Previously, since response (.rsp) files weren't expanded at the very beginning of clang-scan-deps, we only parsed the command-line as provided in the Clang .cdb file. Unfortunately, when using Unreal

[clang] [clang-scan-deps] Expand response files before the argument adjuster (PR #89950)

2024-04-24 Thread Alexandre Ganea via cfe-commits
https://github.com/aganea created https://github.com/llvm/llvm-project/pull/89950 Previously, since response (.rsp) files weren't expanded at the very beginning of clang-scan-deps, we only parsed the command-line as provided in the Clang .cdb file. Unfortunately, when using Unreal Engine,