diff options
author | Alexandre Ganea <aganea@havenstudios.com> | 2024-05-24 17:20:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 17:20:08 -0400 |
commit | 90e33e20a594b8a404af1df93b629137cb605a21 (patch) | |
tree | 9d2181c877add6399ce88a9725010b214474ad26 /clang/tools | |
parent | 56c5ca8f6670a29dc726d65e24fde7dc047b04c3 (diff) | |
download | llvm-90e33e20a594b8a404af1df93b629137cb605a21.zip llvm-90e33e20a594b8a404af1df93b629137cb605a21.tar.gz llvm-90e33e20a594b8a404af1df93b629137cb605a21.tar.bz2 |
[clang-scan-deps] Expand response files before the argument adjuster (#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, arguments are always generated in a .rsp file (ie.
`/path/to/clang-cl.exe @/path/to/filename_args.rsp`).
After this patch, `/Fo` can be parsed and added to the final
command-line. Without this option, the make targets that are emitted are
made up from the input file name alone. We have some cases where the
same input in the project generates several output files, so we end up
with duplicate make targets in the scan-deps emitted dependency file.
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/clang-scan-deps/ClangScanDeps.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index f42af7e..036e57c8 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -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}; static std::vector<const char *> CommandLine; #ifndef NDEBUG @@ -99,8 +101,6 @@ static bool RoundTripArgs = DoRoundTripDefault; static void ParseArgs(int argc, char **argv) { ScanDepsOptTable Tbl; llvm::StringRef ToolName = argv[0]; - llvm::BumpPtrAllocator Alloc; - llvm::StringSaver Saver{Alloc}; llvm::opt::InputArgList Args = Tbl.parseArgs(argc, argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) { llvm::errs() << Msg << '\n'; @@ -792,6 +792,11 @@ 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. + Compilations = expandResponseFiles(std::move(Compilations), + llvm::vfs::getRealFileSystem()); + // The command options are rewritten to run Clang in preprocessor only mode. auto AdjustingCompilations = std::make_unique<tooling::ArgumentsAdjustingCompilations>( |