Skip to content

Conversation

Xazax-hun
Copy link
Contributor

@Xazax-hun Xazax-hun commented Sep 5, 2025

Explanation: Anonymous structs cannot be copied or moved, these operations only can happen to their enclosing non-anonymous types. Stop trying to emit special member functions and value witness tables for these structs. This fix is required to unblock a high priority libc++ change that fixes an unintended ABI break.
Issues: rdar://159928354
Original PRs: #84105, #84152, #84199
Risk: Medium. I believe this is the right change but hard to anticipate if something depends on the presence of these operations (which is likely to be a bug). But this is required to unblock an important libc++ fix.
Testing: Added a compiler test.
Reviewers: @rjmccall

…ble fields

Explanation: Anonymous structs cannot be copied or moved, these operations only
can happen to their enclosing non-anonymous types. Stop trying to emit special
member functions and value witness tables for these structs. This fix is
required to unblock a high priority libc++ change that fixes an
unintended ABI break.
Issues: rdar://159928354
Original PRs: swiftlang#84105
Risk: Medium. I believe this is the right change but hard to anticipate
if something depends on the presence of these operations (which is
likely to be a bug). But this is required to unblock an important libc++
fix.
Testing: Added a compiler test.
Reviewers: @rjmccall
@Xazax-hun Xazax-hun requested a review from a team as a code owner September 5, 2025 10:00
@Xazax-hun Xazax-hun added c++ interop Feature: Interoperability with C++ 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Sep 5, 2025
if (auto cd = Target->getClangDecl())
if (auto rd = dyn_cast<clang::RecordDecl>(cd))
if (rd->isAnonymousStructOrUnion())
return;
Copy link
Member

Choose a reason for hiding this comment

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

This early return is going to mean that the builder has the wrong size for the data structure. If we must handle things at this level (rather than, say, making emitValueWitnessTable put in stubs for the special member functions for such types). Worst case we could add a null here or a dummy symbol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a null here to preserve the size while talking about the stubs offline.

…data

[cxx-interop] Make the size of anonymous types metadata is unchanged
…types

[cxx-interop] Restrict the uses of anonymous types
@Xazax-hun
Copy link
Contributor Author

@swift-ci please test

@Xazax-hun
Copy link
Contributor Author

Updated with some follow-up PRs to not generate reflection for anonymous fields and disallow referring to them directly.

@Xazax-hun Xazax-hun merged commit 859f60d into swiftlang:release/6.2 Sep 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++ 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants