Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions lib/PrintAsClang/PrintClangValueType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,33 +330,7 @@ void ClangValueTypePrinter::printValueTypeDecl(
os << " }\n";

// FIXME: implement the move assignment.
os << " ";
printer.printInlineForThunk();
printer.printBaseName(typeDecl);
os << " &operator =(";
printer.printBaseName(typeDecl);
os << " &&other) = delete;\n";

// FIXME: implement the move constructor.
os << " [[noreturn]] ";
// NOTE: Do not apply attribute((used))
// here to ensure the linker error isn't
// forced, so just mark this an inline
// helper function instead.
printer.printInlineForHelperFunction();
printer.printBaseName(typeDecl);
os << "(";
printer.printBaseName(typeDecl);
StringRef moveErrorMessage =
"C++ does not support moving a Swift value yet";
os << " &&) noexcept {\n "
"swift::_impl::_fatalError_Cxx_move_of_Swift_value_type_not_"
"supported_"
"yet();\n swift::_impl::_swift_stdlib_reportFatalError(\"swift\", "
"5, "
"\""
<< moveErrorMessage << "\", " << moveErrorMessage.size()
<< ", 0);\n abort();\n }\n";

bodyPrinter();
if (typeDecl->isStdlibDecl())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public final class ExposedClass {
// CHECK: class SWIFT_SYMBOL("{{.*}}") ExposedClass final
// CHECK: class SWIFT_SYMBOL("{{.*}}") ExposedStruct final {
// CHECK: class SWIFT_SYMBOL("{{.*}}") ExposedStruct2 final {
// CHECK: ExposedStruct2(ExposedStruct2 &&)
// CHECK: SWIFT_INLINE_THUNK ExposedStruct2 &operator =(const ExposedStruct2 &other) noexcept {
// CHECK: }
// CHECK-NEXT: swift::Int getY() const SWIFT_SYMBOL("{{.*}}");
// CHECK-NEXT: void setY(swift::Int value) SWIFT_SYMBOL("{{.*}}");
Expand Down
2 changes: 1 addition & 1 deletion test/Interop/SwiftToCxx/initializers/init-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct FirstSmallStruct {

// CHECK: class SWIFT_SYMBOL("s:4Init16FirstSmallStructV") FirstSmallStruct final {
// CHECK-NEXT: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER FirstSmallStruct(FirstSmallStruct &&)
// CHECK: SWIFT_INLINE_THUNK FirstSmallStruct &operator =(const FirstSmallStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK uint32_t getX() const SWIFT_SYMBOL("s:4Init16FirstSmallStructV1xs6UInt32Vvp");
// CHECK-NEXT: static SWIFT_INLINE_THUNK FirstSmallStruct init() SWIFT_SYMBOL("s:4Init16FirstSmallStructVACycfc");
Expand Down
2 changes: 1 addition & 1 deletion test/Interop/SwiftToCxx/methods/method-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public final class PassStructInClassMethod {
// CHECK-NEXT: static SWIFT_INLINE_THUNK LargeStruct staticFinalClassMethod(swift::Int x) SWIFT_SYMBOL("s:7Methods09ClassWithA0C011staticFinalB6Method1xAA11LargeStructVSi_tFZ");

// CHECK: class SWIFT_SYMBOL("s:7Methods11LargeStructV") LargeStruct final {
// CHECK: SWIFT_INLINE_PRIVATE_HELPER LargeStruct(LargeStruct &&)
// CHECK: SWIFT_INLINE_THUNK LargeStruct &operator =(const LargeStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK LargeStruct doubled() const SWIFT_SYMBOL("s:7Methods11LargeStructV7doubledACyF");
// CHECK-NEXT: SWIFT_INLINE_THUNK void dump() const SWIFT_SYMBOL("s:7Methods11LargeStructV4dumpyyF");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public struct SmallStruct {
// CHECK: SWIFT_EXTERN void $s7Methods11SmallStructV6invertyyF(SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // invert()

// CHECK: class SWIFT_SYMBOL("s:7Methods11LargeStructV") LargeStruct final {
// CHECK: SWIFT_INLINE_PRIVATE_HELPER LargeStruct(LargeStruct &&)
// CHECK: SWIFT_INLINE_THUNK LargeStruct &operator =(const LargeStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK void dump() const SWIFT_SYMBOL("s:7Methods11LargeStructV4dumpyyF");
// CHECK-NEXT: SWIFT_INLINE_THUNK void double_() SWIFT_SYMBOL("s:7Methods11LargeStructV6doubleyyF");
// CHECK-NEXT: SWIFT_INLINE_THUNK LargeStruct scale(swift::Int x, swift::Int y) SWIFT_SYMBOL("s:7Methods11LargeStructV5scaleyACSi_SitF");
// CHECK-NEXT: private

// CHECK: class SWIFT_SYMBOL("s:7Methods11SmallStructV") SmallStruct final {
// CHECK: SWIFT_INLINE_PRIVATE_HELPER SmallStruct(SmallStruct &&)
// CHECK: SWIFT_INLINE_THUNK SmallStruct &operator =(const SmallStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK void dump() const SWIFT_SYMBOL("s:7Methods11SmallStructV4dumpyyF");
// CHECK-NEXT: SWIFT_INLINE_THUNK SmallStruct scale(float y) SWIFT_SYMBOL("s:7Methods11SmallStructV5scaleyACSfF");
Expand Down
6 changes: 3 additions & 3 deletions test/Interop/SwiftToCxx/properties/getter-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct FirstSmallStruct {

// CHECK: class SWIFT_SYMBOL({{.*}}) FirstSmallStruct final {
// CHECK: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER FirstSmallStruct(FirstSmallStruct &&)
// CHECK: SWIFT_INLINE_THUNK FirstSmallStruct &operator =(const FirstSmallStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK uint32_t getX() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: private:
Expand All @@ -37,7 +37,7 @@ public struct LargeStruct {

// CHECK: class SWIFT_SYMBOL({{.*}}) LargeStruct final {
// CHECK: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER LargeStruct(LargeStruct &&)
// CHECK: SWIFT_INLINE_THUNK LargeStruct &operator =(const LargeStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK swift::Int getX1() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: SWIFT_INLINE_THUNK swift::Int getX2() const SWIFT_SYMBOL({{.*}});
Expand Down Expand Up @@ -94,7 +94,7 @@ public struct SmallStructWithGetters {

// CHECK: class SWIFT_SYMBOL({{.*}}) SmallStructWithGetters final {
// CHECK: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER SmallStructWithGetters(SmallStructWithGetters &&)
// CHECK: SWIFT_INLINE_THUNK SmallStructWithGetters &operator =(const SmallStructWithGetters &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK uint32_t getStoredInt() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: SWIFT_INLINE_THUNK swift::Int getComputedInt() const SWIFT_SYMBOL({{.*}});
Expand Down
6 changes: 3 additions & 3 deletions test/Interop/SwiftToCxx/properties/setter-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public struct FirstSmallStruct {

// CHECK: class SWIFT_SYMBOL({{.*}}) FirstSmallStruct final {
// CHECK: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER FirstSmallStruct(FirstSmallStruct &&)
// CHECK: SWIFT_INLINE_THUNK FirstSmallStruct &operator =(const FirstSmallStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK uint32_t getX() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: SWIFT_INLINE_THUNK void setX(uint32_t value) SWIFT_SYMBOL({{.*}});
Expand All @@ -32,7 +32,7 @@ public struct LargeStruct {

// CHECK: class SWIFT_SYMBOL({{.*}}) LargeStruct final {
// CHECK: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER LargeStruct(LargeStruct &&)
// CHECK: SWIFT_INLINE_THUNK LargeStruct &operator =(const LargeStruct &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK swift::Int getX1() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: SWIFT_INLINE_THUNK void setX1(swift::Int value) SWIFT_SYMBOL({{.*}});
Expand Down Expand Up @@ -111,7 +111,7 @@ public struct SmallStructWithProps {

// CHECK: class SWIFT_SYMBOL({{.*}}) SmallStructWithProps final {
// CHECK: public:
// CHECK: SWIFT_INLINE_PRIVATE_HELPER SmallStructWithProps(SmallStructWithProps &&)
// CHECK: SWIFT_INLINE_THUNK SmallStructWithProps &operator =(const SmallStructWithProps &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK uint32_t getStoredInt() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: SWIFT_INLINE_THUNK void setStoredInt(uint32_t value) SWIFT_SYMBOL({{.*}});
Expand Down
5 changes: 1 addition & 4 deletions test/Interop/SwiftToCxx/stdlib/swift-stdlib-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK String &operator =(const String &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK String &operator =(String &&other) = delete;
// CHECK-NEXT: SWIFT_INLINE_PRIVATE_HELPER String(String &&) noexcept {
// CHECK: }
// CHECK-NEXT: static SWIFT_INLINE_THUNK String init() SWIFT_SYMBOL({{.*}});
// CHECK: SWIFT_INLINE_THUNK void append(const String& other)
// CHECK: SWIFT_INLINE_THUNK __StringNested::UTF8View getUtf8() const SWIFT_SYMBOL({{.*}});
Expand Down Expand Up @@ -118,7 +115,7 @@
// CHECK-NEXT: private:

// CHECK: class SWIFT_SYMBOL({{.*}}) UTF8View final {
// CHECK: SWIFT_INLINE_PRIVATE_HELPER UTF8View(UTF8View &&) noexcept {
// CHECK: SWIFT_INLINE_THUNK UTF8View &operator =(const UTF8View &other) noexcept {
// CHECK: }
// CHECK-NEXT: SWIFT_INLINE_THUNK __StringNested::Index getStartIndex() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: SWIFT_INLINE_THUNK __StringNested::Index getEndIndex() const SWIFT_SYMBOL({{.*}});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,35 @@
// Link should fail by default when a move is
// performed in C++.
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-structs-execution.o
// RUN: not %target-interop-build-swift %S/large-structs-pass-return-indirect-in-cxx.swift -o %t/swift-structs-execution -Xlinker %t/swift-structs-execution.o -module-name Structs -Xfrontend -entry-point-function-name -Xfrontend swiftMain 2>&1 | %FileCheck --check-prefix=LINK %s

// LINK: fatalError_Cxx_move_of_Swift_value_type_not_supported_yet
// RUN: %target-interop-build-swift %S/large-structs-pass-return-indirect-in-cxx.swift -o %t/swift-structs-execution -Xlinker %t/swift-structs-execution.o -module-name Structs -Xfrontend -entry-point-function-name -Xfrontend swiftMain 2>&1

// Compile should fail by default when move assignment is attempted in C++:

// RUN: not %target-interop-build-clangxx -c %s -I %t -o %t/swift-structs-execution.o -DMOVE_ASSIGN 2>&1 | %FileCheck --check-prefix=MOVEASSIGN %s
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-structs-execution.o -DMOVE_ASSIGN 2>&1

// Fallback to abort at runtime:

// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-structs-execution.o -DLINKS
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-structs-execution.o
// RUN: %target-interop-build-swift %S/large-structs-pass-return-indirect-in-cxx.swift -o %t/swift-structs-execution -Xlinker %t/swift-structs-execution.o -module-name Structs -Xfrontend -entry-point-function-name -Xfrontend swiftMain 2>&1

// RUN: %target-codesign %t/swift-structs-execution
// RUN: %target-run %t/swift-structs-execution 2>%t/output || true
// RUN: cat %t/output | %FileCheck %s

// REQUIRES: executable_test

#include <assert.h>
#include "structs.h"
#include <memory>

#ifdef LINKS
extern "C" void _fatalError_Cxx_move_of_Swift_value_type_not_supported_yet() {

}
#endif

int main() {
using namespace Structs;

auto x = returnNewStructSeveralI64(42);
#ifdef MOVE_ASSIGN
auto y = returnNewStructSeveralI64(24);
x = std::move(y);
// MOVEASSIGN: deleted operator '='
#else
StructSeveralI64 x2 = std::move(x);
#endif
return 0;
}

// CHECK: C++ does not support moving a Swift value yet
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,4 @@ public func printBreak(_ x: Int) {
// CHECK-NEXT: vwTable->assignWithCopy(_getOpaquePointer(), const_cast<char *>(other._getOpaquePointer()), metadata._0);
// CHECK-NEXT: return *this;
// CHECK-NEXT: }
// CHECK-NEXT: SWIFT_INLINE_THUNK StructWithRefcountedMember &operator =(StructWithRefcountedMember &&other) = delete;
// CHECK-NEXT: SWIFT_INLINE_PRIVATE_HELPER StructWithRefcountedMember(StructWithRefcountedMember &&) noexcept {
// CHECK-NEXT: swift::_impl::_fatalError_Cxx_move_of_Swift_value_type_not_supported_yet();
// CHECK-NEXT: swift::_impl::_swift_stdlib_reportFatalError("swift", 5, "C++ does not support moving a Swift value yet", 45, 0);
// CHECK-NEXT: abort();
// CHECK-NEXT: }
// CHECK-NEXT: private:
6 changes: 0 additions & 6 deletions test/Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@
// CHECK-NEXT: vwTable->assignWithCopy(_getOpaquePointer(), const_cast<char *>(other._getOpaquePointer()), metadata._0);
// CHECK-NEXT: return *this;
// CHECK-NEXT: }
// CHECK-NEXT: SWIFT_INLINE_THUNK StructWithIntField &operator =(StructWithIntField &&other) = delete;
// CHECK-NEXT: noreturn]] SWIFT_INLINE_PRIVATE_HELPER StructWithIntField(StructWithIntField &&) noexcept {
// CHECK-NEXT: swift::_impl::_fatalError_Cxx_move_of_Swift_value_type_not_supported_yet();
// CHECK-NEXT: swift::_impl::_swift_stdlib_reportFatalError("swift", 5, "C++ does not support moving a Swift value yet", 45, 0);
// CHECK-NEXT: abort();
// CHECK-NEXT: }
// CHECK-NEXT: private:
// CHECK-NEXT: SWIFT_INLINE_THUNK StructWithIntField() noexcept {}
// CHECK-NEXT: static SWIFT_INLINE_THUNK StructWithIntField _make() noexcept { return StructWithIntField(); }
Expand Down