@@ -93,6 +93,21 @@ extern "C" void *_Nonnull swift_retain(void *_Nonnull) noexcept;
9393
9494extern " C" void swift_release (void *_Nonnull) noexcept ;
9595
96+ #pragma clang diagnostic push
97+ #pragma clang diagnostic ignored "-Wreserved-identifier"
98+
99+ extern " C" void _swift_stdlib_reportFatalError (const char *_Nonnull prefix,
100+ int prefixLength,
101+ const char *_Nonnull message,
102+ int messageLength,
103+ uint32_t flags) noexcept ;
104+
105+ // A dummy symbol that forces a linker error when
106+ // C++ tries to invoke a move of a Swift value type.
107+ extern " C" void _fatalError_Cxx_move_of_Swift_value_type_not_supported_yet ();
108+
109+ #pragma clang diagnostic pop
110+
96111SWIFT_INLINE_THUNK void *_Nonnull opaqueAlloc (size_t size,
97112 size_t align) noexcept {
98113#if defined(_WIN32)
@@ -159,18 +174,28 @@ class RefCountedClass {
159174 : _opaquePointer(other._opaquePointer) {
160175 swift_retain (_opaquePointer);
161176 }
177+ SWIFT_INLINE_THUNK RefCountedClass (RefCountedClass &&other) noexcept
178+ : _opaquePointer(other._opaquePointer) {
179+ // Moving a Swift class reference is a copy
180+ // in C++. This allows C++ to avoid liveness
181+ // checks to see if the pointer is `null` or not,
182+ // as C++'s move is not consuming, unlike Swift's.
183+ swift_retain (_opaquePointer);
184+ }
162185 SWIFT_INLINE_THUNK RefCountedClass &
163186 operator =(const RefCountedClass &other) noexcept {
164187 swift_retain (other._opaquePointer );
165188 swift_release (_opaquePointer);
166189 _opaquePointer = other._opaquePointer ;
167190 return *this ;
168191 }
169- #pragma clang diagnostic push
170- #pragma clang diagnostic ignored "-Wmissing-noreturn"
171- // FIXME: implement 'move'?
172- SWIFT_INLINE_THUNK RefCountedClass (RefCountedClass &&) noexcept { abort (); }
173- #pragma clang diagnostic pop
192+ SWIFT_INLINE_THUNK RefCountedClass &
193+ operator =(RefCountedClass &&other) noexcept {
194+ swift_retain (other._opaquePointer );
195+ swift_release (_opaquePointer);
196+ _opaquePointer = other._opaquePointer ;
197+ return *this ;
198+ }
174199
175200protected:
176201 SWIFT_INLINE_THUNK RefCountedClass (void *_Nonnull ptr) noexcept
0 commit comments