Skip to content

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.

3 participants