Skip to content

[cxx-interop][SwiftCompilerSources] Do not use SWIFT_IMPORT_UNSAFE with BridgedOwnedString #76408

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
Sep 16, 2024

Conversation

egorzhdan
Copy link
Contributor

SWIFT_IMPORT_UNSAFE is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

BridgedOwnedString fits into the definition of a self-contained C++ type in Swift: it manages the lifetimes of its own fields.

This removes the usages of SWIFT_IMPORT_UNSAFE for C++ functions that return BridgedOwnedString, and annotates BridgedOwnedString as a self-contained type.

…with `BridgedOwnedString`

`SWIFT_IMPORT_UNSAFE` is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

`BridgedOwnedString` fits into the definition of a self-contained C++ type in Swift: it manages the lifetimes of its own fields.

This removes the usages of `SWIFT_IMPORT_UNSAFE` for C++ functions that return `BridgedOwnedString`, and annotates `BridgedOwnedString` as a self-contained type.
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Sep 11, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

@egorzhdan egorzhdan marked this pull request as ready for review September 12, 2024 10:38
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@egorzhdan egorzhdan merged commit 586ac09 into main Sep 16, 2024
3 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/scs-owned-string branch September 16, 2024 19:00
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