Skip to content

Commit 6424835

Browse files
authored
Merge pull request #61224 from hyp/eng/prohibit-moves
[interop][SwiftToCxx] trap on moves of Swift values for now
2 parents b28efc5 + 1d6d3ff commit 6424835

File tree

11 files changed

+22
-19
lines changed

11 files changed

+22
-19
lines changed

lib/PrintAsClang/PrintClangValueType.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ void ClangValueTypePrinter::printValueTypeDecl(
263263
"*>(other._getOpaquePointer()), metadata._0);\n";
264264
os << " }\n";
265265

266-
// FIXME: the move constructor should be hidden somehow.
267-
os << " inline ";
266+
// FIXME: implement the move constructor.
267+
os << " [[noreturn]] inline ";
268268
printer.printBaseName(typeDecl);
269269
os << "(";
270270
printer.printBaseName(typeDecl);
271-
os << " &&) = default;\n";
271+
os << " &&) { abort(); }\n";
272272

273273
bodyPrinter();
274274
if (typeDecl->isStdlibDecl())

stdlib/public/SwiftShims/swift/shims/_SwiftCxxInteroperability.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ class RefCountedClass {
103103
_opaquePointer = other._opaquePointer;
104104
return *this;
105105
}
106-
// FIXME: What to do in 'move'?
107-
inline RefCountedClass(RefCountedClass &&) noexcept = default;
106+
#pragma clang diagnostic push
107+
#pragma clang diagnostic ignored "-Wmissing-noreturn"
108+
// FIXME: implement 'move'?
109+
inline RefCountedClass(RefCountedClass &&) noexcept { abort(); }
110+
#pragma clang diagnostic pop
108111

109112
protected:
110113
inline RefCountedClass(void *_Nonnull ptr) noexcept : _opaquePointer(ptr) {}

test/Interop/SwiftToCxx/expose-attr/expose-swift-decls-to-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public final class ExposedClass {
7777
// CHECK: class ExposedClass final
7878
// CHECK: class ExposedStruct final {
7979
// CHECK: class ExposedStruct2 final {
80-
// CHECK: ExposedStruct2(ExposedStruct2 &&) = default;
80+
// CHECK: ExposedStruct2(ExposedStruct2 &&)
8181
// CHECK-NEXT: swift::Int getY() const;
8282
// CHECK-NEXT: void setY(swift::Int value);
8383
// CHECK-NEXT: static inline ExposedStruct2 init();

test/Interop/SwiftToCxx/initializers/init-in-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public struct FirstSmallStruct {
3232

3333
// CHECK: class FirstSmallStruct final {
3434
// CHECK-NEXT: public:
35-
// CHECK: inline FirstSmallStruct(FirstSmallStruct &&) = default;
35+
// CHECK: inline FirstSmallStruct(FirstSmallStruct &&)
3636
// CHECK-NEXT: inline uint32_t getX() const;
3737
// CHECK-NEXT: static inline FirstSmallStruct init();
3838
// CHECK-NEXT: static inline FirstSmallStruct init(swift::Int x);

test/Interop/SwiftToCxx/methods/method-in-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public final class PassStructInClassMethod {
8585
// CHECK-NEXT: inline ClassWithMethods deepCopy(swift::Int x);
8686

8787
// CHECK: class LargeStruct final {
88-
// CHECK: inline LargeStruct(LargeStruct &&) = default;
88+
// CHECK: inline LargeStruct(LargeStruct &&)
8989
// CHECK-NEXT: inline LargeStruct doubled() const;
9090
// CHECK-NEXT: inline void dump() const;
9191
// CHECK-NEXT: inline LargeStruct scaled(swift::Int x, swift::Int y) const;

test/Interop/SwiftToCxx/methods/mutating-method-in-cxx.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public struct SmallStruct {
5757
// CHECK: SWIFT_EXTERN void $s7Methods11SmallStructV6invertyyF(SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // invert()
5858

5959
// CHECK: class LargeStruct final {
60-
// CHECK: inline LargeStruct(LargeStruct &&) = default;
60+
// CHECK: inline LargeStruct(LargeStruct &&)
6161
// CHECK-NEXT: inline void dump() const;
6262
// CHECK-NEXT: inline void double_();
6363
// CHECK-NEXT: inline LargeStruct scale(swift::Int x, swift::Int y);
6464
// CHECK-NEXT: private
6565

6666
// CHECK: class SmallStruct final {
67-
// CHECK: inline SmallStruct(SmallStruct &&) = default;
67+
// CHECK: inline SmallStruct(SmallStruct &&)
6868
// CHECK-NEXT: inline void dump() const;
6969
// CHECK-NEXT: inline SmallStruct scale(float y);
7070
// CHECK-NEXT: inline void invert();

test/Interop/SwiftToCxx/properties/getter-in-cxx.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct FirstSmallStruct {
1010

1111
// CHECK: class FirstSmallStruct final {
1212
// CHECK: public:
13-
// CHECK: inline FirstSmallStruct(FirstSmallStruct &&) = default;
13+
// CHECK: inline FirstSmallStruct(FirstSmallStruct &&)
1414
// CHECK-NEXT: inline uint32_t getX() const;
1515
// CHECK-NEXT: private:
1616

@@ -28,7 +28,7 @@ public struct LargeStruct {
2828

2929
// CHECK: class LargeStruct final {
3030
// CHECK: public:
31-
// CHECK: inline LargeStruct(LargeStruct &&) = default;
31+
// CHECK: inline LargeStruct(LargeStruct &&)
3232
// CHECK-NEXT: inline swift::Int getX1() const;
3333
// CHECK-NEXT: inline swift::Int getX2() const;
3434
// CHECK-NEXT: inline swift::Int getX3() const;
@@ -82,7 +82,7 @@ public struct SmallStructWithGetters {
8282

8383
// CHECK: class SmallStructWithGetters final {
8484
// CHECK: public:
85-
// CHECK: inline SmallStructWithGetters(SmallStructWithGetters &&) = default;
85+
// CHECK: inline SmallStructWithGetters(SmallStructWithGetters &&)
8686
// CHECK-NEXT: inline uint32_t getStoredInt() const;
8787
// CHECK-NEXT: inline swift::Int getComputedInt() const;
8888
// CHECK-NEXT: inline LargeStruct getLargeStruct() const;

test/Interop/SwiftToCxx/properties/setter-in-cxx.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public struct FirstSmallStruct {
1010

1111
// CHECK: class FirstSmallStruct final {
1212
// CHECK: public:
13-
// CHECK: inline FirstSmallStruct(FirstSmallStruct &&) = default;
13+
// CHECK: inline FirstSmallStruct(FirstSmallStruct &&)
1414
// CHECK-NEXT: inline uint32_t getX() const;
1515
// CHECK-NEXT: inline void setX(uint32_t value);
1616
// CHECK-NEXT: private:
@@ -21,7 +21,7 @@ public struct LargeStruct {
2121

2222
// CHECK: class LargeStruct final {
2323
// CHECK: public:
24-
// CHECK: inline LargeStruct(LargeStruct &&) = default;
24+
// CHECK: inline LargeStruct(LargeStruct &&)
2525
// CHECK-NEXT: inline swift::Int getX1() const;
2626
// CHECK-NEXT: inline void setX1(swift::Int value);
2727
// CHECK-NEXT: inline swift::Int getX2() const;
@@ -97,7 +97,7 @@ public struct SmallStructWithProps {
9797

9898
// CHECK: class SmallStructWithProps final {
9999
// CHECK: public:
100-
// CHECK: inline SmallStructWithProps(SmallStructWithProps &&) = default;
100+
// CHECK: inline SmallStructWithProps(SmallStructWithProps &&)
101101
// CHECK-NEXT: inline uint32_t getStoredInt() const;
102102
// CHECK-NEXT: inline void setStoredInt(uint32_t value);
103103
// CHECK-NEXT: inline swift::Int getComputedInt() const;

test/Interop/SwiftToCxx/stdlib/swift-stdlib-in-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
// CHECK: }
5353
// CHECK-NEXT: inline String(const String &other) {
5454
// CHECK: }
55-
// CHECK-NEXT: inline String(String &&) = default;
55+
// CHECK-NEXT: inline String(String &&) { abort(); }
5656
// CHECK-NEXT: static inline String init();
5757
// CHECK-NEXT: #if defined(__OBJC__)
5858
// CHECK-NEXT: inline __attribute__((always_inline)) operator NSString * _Nonnull () const noexcept {

test/Interop/SwiftToCxx/structs/struct-with-refcounted-member.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ public func printBreak(_ x: Int) {
4747
// CHECK-NEXT: #endif
4848
// CHECK-NEXT: vwTable->initializeWithCopy(_getOpaquePointer(), const_cast<char *>(other._getOpaquePointer()), metadata._0);
4949
// CHECK-NEXT: }
50-
// CHECK-NEXT: inline StructWithRefcountedMember(StructWithRefcountedMember &&) = default;
50+
// CHECK-NEXT: inline StructWithRefcountedMember(StructWithRefcountedMember &&) { abort(); }
5151
// CHECK-NEXT: private:

test/Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// CHECK: }
2626
// CHECK-NEXT: inline StructWithIntField(const StructWithIntField &other) {
2727
// CHECK: }
28-
// CHECK-NEXT: inline StructWithIntField(StructWithIntField &&) = default;
28+
// CHECK-NEXT: noreturn]] inline StructWithIntField(StructWithIntField &&) { abort(); }
2929
// CHECK-NEXT: private:
3030
// CHECK-NEXT: inline StructWithIntField() {}
3131
// CHECK-NEXT: static inline StructWithIntField _make() { return StructWithIntField(); }

0 commit comments

Comments
 (0)