[clang][deps] Use top-level modules as precompiled dependencies
authorJan Svoboda <jan_svoboda@apple.com>
Wed, 25 Aug 2021 08:36:03 +0000 (10:36 +0200)
committerJan Svoboda <jan_svoboda@apple.com>
Wed, 25 Aug 2021 08:51:34 +0000 (10:51 +0200)
commit3b8f536fec2f7dfd5dc69c6516c20c5b48b38409
treed28514926da29bbda0c17909966d28935fb622b2
parent46c947af7ead0a939fbd7a93c370e7ead2128d07
[clang][deps] Use top-level modules as precompiled dependencies

The `ASTReader` populates `Module::PresumedModuleMapFile` only for top-level modules, not submodules. To avoid generating empty `-fmodule-map-file=` arguments, make discovered modules depend on top-level precompiled modules. The granularity of submodules is not important here.

The documentation of `Module::PresumedModuleMapFile` says this field is non-empty only when building from preprocessed source. This means there can still be cases where the dependency scanner generates empty `-fmodule-map-file=` arguments. That's being addressed in separate patch: D108544.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D108647
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common_sub.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/module.modulemap [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/pch.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/tu.c [new file with mode: 0644]
clang/test/ClangScanDeps/modules-pch-common-submodule.c [new file with mode: 0644]