[6.1 🍒][Dependency Scanning] Refine cross-import overlay detection algorithm #80651
+332
−135
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.
Cherry-pick of #79550, #79676, #79809
Explanation: Previous implementation took the entire transitive dependency set and cross-referenced all of its members to determine which ones introduce requried cross-import overlays. That implementation differed from the cross-import overlay loading logic during source compilation, where a corresponding cross-import overlay module is only requested if the two constituent modules are reachable via direct 'import's from the same source file or an indirect
@_exported
import from a direct import. Meaning the dependency scanner before this change would report cross-import overlay dependencies which never got loaded by the corresponding client source compile.This change implements a new implementation of cross-import overlay discovery which first computes sub-graphs of module dependencies directly reachable by 'import's for each source file of the module under scan and then performs pairwise cross-import overlay query per each such subgraph.
Issue: rdar://145157171
Risk: Minimal where explicitly-built modules are not enabled, Low where they are enabled - this change reduces the set of brought-in cross-import overlays in the scanner to match the behavior during the actual source compile. Still, it is a significant change to the cross-import overlay discovery functionality in the scanner to achieve the resulting sound outcome.
Testing: Added tests to test suite
Original PRs: #79550, #79676, #79809
Reviewers: @xymus, @cachemeifyoucan