Skip to content

🍒[APINotes] Allow annotating a C++ type as non-copyable in Swift #8671

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
May 1, 2024

Conversation

egorzhdan
Copy link

Certain C++ types, such as std::chrono::tzdb in libstdc++, are non-copyable, but don't explicitly delete their copy constructor. Instead, they trigger template instantiation errors when trying to call their implicit copy constructor. The Swift compiler inserts implicit copies of value types in some cases, which trigger compiler errors for such types.

This adds a Clang API Notes attribute that allows annotating C++ types as non-copyable in Swift. This lets the Swift compiler know that it should not try to instantiate the implicit copy constructor for a C++ struct.

rdar://127049438
(cherry picked from commit b2098db)

Original PR: llvm#90064

@egorzhdan egorzhdan requested a review from compnerd May 1, 2024 18:26
Certain C++ types, such as `std::chrono::tzdb` in libstdc++, are
non-copyable, but don't explicitly delete their copy constructor.
Instead, they trigger template instantiation errors when trying to call
their implicit copy constructor. The Swift compiler inserts implicit
copies of value types in some cases, which trigger compiler errors for
such types.

This adds a Clang API Notes attribute that allows annotating C++ types
as non-copyable in Swift. This lets the Swift compiler know that it
should not try to instantiate the implicit copy constructor for a C++
struct.

rdar://127049438
(cherry picked from commit b2098db)
@egorzhdan egorzhdan force-pushed the egorzhdan/20240408-apinotes-noncopyable branch from 267ac20 to 83b7524 Compare May 1, 2024 19:12
@egorzhdan egorzhdan merged commit fa31170 into stable/20240408 May 1, 2024
@egorzhdan egorzhdan deleted the egorzhdan/20240408-apinotes-noncopyable branch May 1, 2024 20:15
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.

2 participants