[Dependency Scanning] Post-process imports that fail to resolve against the cache entries added by other resolved imports #68849
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is possible that import resolution failed because we are attempting to resolve a module which can only be brought in via a
.modulemap
of a different Clang module dependency which is not otherwise on the current search paths. For example, suppose we are scanning a.swiftinterface
for moduleFoo
, which contains:Where
Foo
is the underlying Framework clang module whose.modulemap
defines an auxiliary moduleBar
. BecauseFoo
is a framework, its.modulemap
is under<some_framework_search_path>/Foo.framework/Modules/module.modulemap
. Which means that lookup ofBar
alone from Swift will not be able to locate the module in it. However, the lookup ofFoo
will itself bring in the auxiliary module because the Clang scanner instance scanning for clang moduleFoo
will be able to find it in the corresponding framework module's.modulemap
and register it as a dependency which means it will be registered with the scanner's cache. To handle such cases, we first add all successfully-resolved modules and (for Clang modules) their transitive dependencies to the cache, and then attempt to re-query imports for which resolution originally failed from the cache. If this fails, then the scanner genuinely failed to resolve this dependency.