[clang][deps] Give the fake file a unique name in by-module-name scans
authorJan Svoboda <jan_svoboda@apple.com>
Wed, 1 Feb 2023 21:42:19 +0000 (13:42 -0800)
committerJan Svoboda <jan_svoboda@apple.com>
Wed, 1 Feb 2023 21:46:26 +0000 (13:46 -0800)
commit8e9f62e5f833cb89b57bf4c9e80e850bcac7e15e
tree478b5bae88a98077a0efe3704dc85b112678548d
parentba556660fe52a558c34556866aba4a0bb8bbbd23
[clang][deps] Give the fake file a unique name in by-module-name scans

When scanning dependencies of a module, the command line we're given doesn't have an input file, which the driver needs to be happy. We've been creating a fake in-memory input file named after the module. However, this can hide files/directories on the actual filesystem, leading to errors.

This patch works around that issue by generating a unique file name, which won't collide with the actual file system.

We could also change the driver APIs so that we're able to specify an "assumed" input file. This would be more work, though, since the driver assumes the input name comes from the actual command-line.

Depends on D140176.

Reviewed By: artemcm

Differential Revision: https://reviews.llvm.org/D140177
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/test/ClangScanDeps/Inputs/modules_cdb_by_mod_name.json [deleted file]
clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json [deleted file]
clang/test/ClangScanDeps/modules-full-by-mod-name.c [new file with mode: 0644]
clang/test/ClangScanDeps/modules-full-by-mod-name.cpp [deleted file]