[clang-scan-deps] ignore top-level module dependencies that aren't actually imported
authorAlex Lorenz <arphaman@gmail.com>
Thu, 15 Jul 2021 20:52:38 +0000 (13:52 -0700)
committerAlex Lorenz <arphaman@gmail.com>
Tue, 20 Jul 2021 18:11:28 +0000 (11:11 -0700)
commitc68f247275eed94a4f4b97ad53b4d599acfd181a
tree5d2350b58b4f2a607aa25f32d9159b57f29e2172
parent1a762f93f81640768dc9e9d933780fff32cfa639
[clang-scan-deps] ignore top-level module dependencies that aren't actually imported

Whenever -fmodule-name=top_level_module name is parsed, and clang actually tries to
import top_level_module, the headers are imported textually and the module isn't actually
built. However, the dependency scanner could still record it as a potential dependency
if the module was reimported and thus recorded by the preprocessor callbacks.
This change avoids collecting this kind of module as a dependency by verifying that we don't
collect top level modules without actual PCM files.

Differential Revision: https://reviews.llvm.org/D106100
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/header3.h [new file with mode: 0644]
clang/test/ClangScanDeps/Inputs/module.modulemap
clang/test/ClangScanDeps/Inputs/module_fmodule_name_cdb.json [new file with mode: 0644]
clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m [new file with mode: 0644]