[5.3][IDE][DocSupport] Fix DocInfo missing decls when generated for clang submodules. #31596
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 #31589 for 5.3.
Explantion
Our handling of clang submodules was different between sourcekitd's DocInfo and InterfaceGen requests. For InterfaceGen submodules were mapped back to their top-level clang modules (or their Swift overlay if it had one) before being passed into
printSubmoduleInterface
, along with the dot separated name of the submodule.For DocInfo, they were not, and only the rightmost component of their name was passed. The call to retrieve the decls from a ModuleDecl doesn't work if the ModuleDecl wraps a clang submodule, so we were missing these decls.
InterfaceGen for submodules also shouldn't have been mapping back to the overlays of their top-level clang modules, but instead just the top-level clang modules themselves, as that meant we ended up printing import decls from the Swift overlay in the submodule interfaces.
Scope of issue: User-facing generated interfaces would include imports that weren't present in the original module for clang submodule interfaces, and DocInfo for clang submodules would be missing most decls they contained.
Origination: Unclear. I suspect this has been an issue for a long time.
Risk: Low. This only impacts sourcekitd (not the compiler) and only the DocInfo and InterfaceGen requests.
Testing: Added a regression test for these cases and all existing tests pass. Also verified interface generation for clang submodules works in Xcode after these changes.
Reviewer: Argyrios Kyrtzidis (@akyrtzi) on the master branch PR.
Resolves rdar://problem/57338105