Skip to content

[cxx-interop] Remove duplicated logic to import types as unsafe #79458

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
Feb 18, 2025

Conversation

Xazax-hun
Copy link
Contributor

After PR #79424 was merged the compiler proper is doing inference on what C++ types should be considered unsafe. Remove the duplicated (and slightly divergent) logic from the importer as we no longer need it and we should have a consistent view of what is considered unsafe. The only divergence left is the old logic that renames some methods to have "Unsafe" in their names. In the future, we want to get rid of this behavior (potentially under a new interop version).

After PR #79424 was merged the compiler proper is doing inference on
what C++ types should be considered unsafe. Remove the duplicated (and
slightly divergent) logic from the importer as we no longer need it and
we should have a consistent view of what is considered unsafe. The only
divergence left is the old logic that renames some methods to have
"Unsafe" in their names. In the future, we want to get rid of this
behavior (potentially under a new interop version).
@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Feb 18, 2025
@Xazax-hun Xazax-hun requested a review from DougGregor February 18, 2025 12:25
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

// Most STL containers have std::allocator as their default allocator. We need
// to consider std::allocator safe for the STL containers to be ever
// considered safe.
if (decl->isInStdNamespace() && decl->getIdentifier() &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We no longer need this exception as unannotated types without pointer members are considered safe now.

Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

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

LGTM!

@Xazax-hun Xazax-hun merged commit 9153155 into main Feb 18, 2025
3 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/unsafe-cleanup branch February 18, 2025 20:33
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