diff --git a/lib/SIL/IR/TypeLowering.cpp b/lib/SIL/IR/TypeLowering.cpp index 06a4273f92dc1..2d5535bb421ef 100644 --- a/lib/SIL/IR/TypeLowering.cpp +++ b/lib/SIL/IR/TypeLowering.cpp @@ -1453,6 +1453,7 @@ namespace { if (D->isCxxNotTriviallyCopyable()) { properties.setAddressOnly(); + properties.setNonTrivial(); } auto subMap = structType->getContextSubstitutionMap(&TC.M, D); diff --git a/test/Interop/Cxx/class/Inputs/module.modulemap b/test/Interop/Cxx/class/Inputs/module.modulemap index d4460da89db64..24cde705fcde9 100644 --- a/test/Interop/Cxx/class/Inputs/module.modulemap +++ b/test/Interop/Cxx/class/Inputs/module.modulemap @@ -2,8 +2,8 @@ module AccessSpecifiers { header "access-specifiers.h" } -module LoadableTypes { - header "loadable-types.h" +module TypeClassification { + header "type-classification.h" } module MemberwiseInitializer { diff --git a/test/Interop/Cxx/class/Inputs/loadable-types.h b/test/Interop/Cxx/class/Inputs/type-classification.h similarity index 99% rename from test/Interop/Cxx/class/Inputs/loadable-types.h rename to test/Interop/Cxx/class/Inputs/type-classification.h index 5f92b6ef7d089..785c5ef278a73 100644 --- a/test/Interop/Cxx/class/Inputs/loadable-types.h +++ b/test/Interop/Cxx/class/Inputs/type-classification.h @@ -80,7 +80,7 @@ struct StructWithSubobjectMoveAssignment { }; struct StructWithDestructor { - ~StructWithDestructor(){} + ~StructWithDestructor() {} }; struct StructWithInheritedDestructor : StructWithDestructor {}; diff --git a/test/Interop/Cxx/class/loadable-types-silgen.swift b/test/Interop/Cxx/class/type-classification-loadable-silgen.swift similarity index 99% rename from test/Interop/Cxx/class/loadable-types-silgen.swift rename to test/Interop/Cxx/class/type-classification-loadable-silgen.swift index 7611f5d73d747..9681aa3d9b333 100644 --- a/test/Interop/Cxx/class/loadable-types-silgen.swift +++ b/test/Interop/Cxx/class/type-classification-loadable-silgen.swift @@ -3,7 +3,7 @@ // This test checks that we classify C++ types as loadable and address-only // correctly. -import LoadableTypes +import TypeClassification // Tests for individual special members diff --git a/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift new file mode 100644 index 0000000000000..a4ba0bdaccbe0 --- /dev/null +++ b/test/Interop/Cxx/class/type-classification-non-trivial-silgen.swift @@ -0,0 +1,25 @@ +// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-sil %s | %FileCheck %s + +import TypeClassification + +// Make sure that "StructWithDestructor" is marked as non-trivial by checking for a +// "destroy_addr". +// CHECK-LABEL: @$s4main24testStructWithDestructoryyF +// CHECK: [[AS:%.*]] = alloc_stack $StructWithDestructor +// CHECK: destroy_addr [[AS]] +// CHECK-LABEL: end sil function '$s4main24testStructWithDestructoryyF' +public func testStructWithDestructor() { + let d = StructWithDestructor() +} + +// Make sure that "HasMemberWithDestructor" is marked as non-trivial by checking +// for a "destroy_addr". +// CHECK-LABEL: @$s4main33testStructWithSubobjectDestructoryyF +// CHECK: [[AS:%.*]] = alloc_stack $StructWithSubobjectDestructor +// CHECK: destroy_addr [[AS]] +// CHECK-LABEL: end sil function '$s4main33testStructWithSubobjectDestructoryyF' +public func testStructWithSubobjectDestructor() { + let d = StructWithSubobjectDestructor() +} + +