Skip to content

[cxx-interop] Tweak C++ type semantics detection #67115

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

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

egorzhdan
Copy link
Contributor

CxxRecordSemanticsKind::ExplicitlyUnsafe and CxxRecordSemanticsKind::UnsafePointerMember were never directly used, and those do not indicate semantics: they indicate safety of the type when used from Swift, which should be handled by another request IsSafeUseOfCxxDecl instead of CxxRecordSemantics.

Having ExplicitlyUnsafe and UnsafePointerMember as semantics indicators was problematic, for instance, for types that are move-only and store a pointer at the same time. Swift allowed the usage of these types (under the rules for UnsafePointerMember types) when move-only types are disabled, and did not apply the move-only attribute on such types when move-only types are enabled.

rdar://110644300

`CxxRecordSemanticsKind::ExplicitlyUnsafe` and `CxxRecordSemanticsKind::UnsafePointerMember` were never directly used, and those do not indicate semantics: they indicate safety of the type when used from Swift, which should be handled by another request `IsSafeUseOfCxxDecl` instead of `CxxRecordSemantics`.

Having `ExplicitlyUnsafe` and `UnsafePointerMember` as semantics indicators was problematic, for instance, for types that are move-only and store a pointer at the same time. Swift allowed the usage of these types (under the rules for `UnsafePointerMember` types) when move-only types are disabled, and did not apply the move-only attribute on such types when move-only types are enabled.

rdar://110644300
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jul 4, 2023
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan marked this pull request as ready for review July 4, 2023 20:42
@egorzhdan egorzhdan removed request for xedin and hborla July 4, 2023 20:42
Copy link
Contributor

@hyp hyp left a comment

Choose a reason for hiding this comment

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

Great, thanks! I noticed that before but didn't get around to removing them.

@egorzhdan egorzhdan merged commit 39a837c into main Jul 5, 2023
@egorzhdan egorzhdan deleted the egorzhdan/cxx-semantics-kind branch July 5, 2023 18:09
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++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants