[clang][deps] Handle modular dependencies present in PCH
authorJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 09:30:26 +0000 (11:30 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Mon, 14 Jun 2021 09:59:35 +0000 (11:59 +0200)
commit4629554f0b664c94ada7c44fe40855d7a9a39820
treeabef5c2fab8449caf77dd9a56a47e599aa11960f
parenta83ef21ff82e4283044fd31470fc6c1bc4b99c51
[clang][deps] Handle modular dependencies present in PCH

When a translation unit uses a PCH and imports the same modules as the PCH, we'd prefer to resolve to those modules instead of inventing new modules and reporting them as modular dependencies. Since the PCH modules have already been built nudge the compiler to reuse them when deciding whether to build a new module and don't report them as regular modular dependencies.

Depends on D103524 & D103802.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D103526
16 files changed:
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/modules-pch/cdb_pch.json [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch/cdb_tu_with_common.json [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch/mod_common_1.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch/mod_common_2.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch/mod_pch.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch/mod_tu_with_common.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch/module.modulemap
clang/test/ClangScanDeps/Inputs/modules-pch/pch.h
clang/test/ClangScanDeps/Inputs/modules-pch/tu_with_common.c [new file with mode: 0644]
clang/test/ClangScanDeps/modules-pch.c