[clang][deps] Account for transitive spurious dependencies
authorJan Svoboda <jan_svoboda@apple.com>
Tue, 24 Jan 2023 17:31:04 +0000 (09:31 -0800)
committerJan Svoboda <jan_svoboda@apple.com>
Tue, 24 Jan 2023 17:48:58 +0000 (09:48 -0800)
commit96a54b2258cddcb52f8c98e760b9b114a1aa4034
tree7bd6d85aefc705e8248e47ed4362da92e6afeeb0
parent8202a3da3c897fc663f55ae5c638ae56f11543c1
[clang][deps] Account for transitive spurious dependencies

In D106100, we started guarding against spurious dependencies on modules that ended up being textual includes and thus didn't have any AST file associated. That patch accounted only for direct dependencies. There's a way how to get spurious dependencies for modules that are transitive. This patch guards against that scenario and adds a test case.

(Note that since D142167, we don't allow `@import FW_Private` with `-fmodule-name=FW` anymore. However, that check lives in sema, which the scanner doesn't run. Being defensive in this patch therefore still makes sense.)

rdar://104324602

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D142165
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-implementation-private.m [new file with mode: 0644]