🍒 [6.2] Fix interop private debug symbols 6.2 #80718
Merged
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 #80515, #80485
Explanation: The patch from #80485 fixes an assertion failure/compiler crash that is hit when the compiler tries to generate debug info for a private type decl imported from Clang. The assertion failure typically happens when we deliberately import private nested types (e.g., with the
ImportNonPublicCxxMembers
flag), but has been reported to occur in at least one adopter project that isn't using this feature flag.The assertion failure is here, and is reached when one calls
getFilePrivateScope()
with a Clang decl. When it is compiled out in a no-assertions build, the compiler simply segfaults.The
getFilePrivateScope()
function is normally necessary to disambiguate the debug info generated for Swift types withprivate
orfileprivate
access, because multiple such types of the same name may exist in different files due to Swift's scoping rules. This is not so for types imported from Clang, because access specifiers do not affect lexical scope in C/C++.#80515 is a precursor to #80485 that does not modify the compiler. I'm including #80515 in this cherry-pick because it introduces a test case that #80485 builds upon.
Issue: rdar://148481025
Risk: Low. The only compiler adjustment in this patch is an additional check that avoids generating a discriminator for Clang decls. Any call to
getFilePrivateScope()
that used to happen successfully will continue to do so.Testing: Added test to test suite
Original PRs: #80515, #80485
Reviewers: @egorzhdan @Xazax-hun @fahadnayyar