Skip to content

🍒 [6.2] [cxx-interop] Avoid querying layout of dependent types during symbolic import #81235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented May 1, 2025

Explanation: This patch avoids querying the ASTRecordLayout of [[no_unique_address]] fields when symbolic import is enabled. Symbolic import mode causes ClangImporter to import uninstantiated class templates, which may contain dependent-typed fields that trigger an assertion failure when querying their layout (since their layout depends on a non-concrete template argument).

Issue: rdar://150067288
Risk: low
Testing: added tests
Original PRs: #81228
Reviewer: @egorzhdan

j-hui added 3 commits May 1, 2025 10:10
…h a custom type is reused

(cherry picked from commit 5fdbb44)
…c import

In swiftlang#80786, we started importing certain padded fields as opaque blobs.
Part of this logic involved querying those fields' ASTRecordLayout.
However, dependent types (which are imported symbolically) do not have
an ASTRecordLayout, so calling Clang's getASTRecordLayout() would lead
to an assertion error for class templates where a no_unique_address
field is some kind of dependent C++ record type.

This patch avoids the field padding check during symbolic import mode
because that check is only relevant for codegen anyway.

rdar://150067288
(cherry picked from commit 1fdb239)
@j-hui j-hui requested a review from a team as a code owner May 1, 2025 17:18
@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

@swift-ci please test

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a safe change.

@DougGregor DougGregor merged commit 751678d into swiftlang:release/6.2 May 6, 2025
5 checks passed
@j-hui j-hui deleted the cherry-pick-6.2/fix-ast-layout-dependent-types branch May 6, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants