Skip to content

Commit 8cf6e93

Browse files
authored
Merge pull request #32402 from zoecarver/cxx/non-trival-with-destructor
2 parents eadd20a + 13632d4 commit 8cf6e93

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ namespace {
14531453

14541454
if (D->isCxxNotTriviallyCopyable()) {
14551455
properties.setAddressOnly();
1456+
properties.setNonTrivial();
14561457
}
14571458

14581459
auto subMap = structType->getContextSubstitutionMap(&TC.M, D);

test/Interop/Cxx/class/Inputs/module.modulemap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module AccessSpecifiers {
22
header "access-specifiers.h"
33
}
44

5-
module LoadableTypes {
6-
header "loadable-types.h"
5+
module TypeClassification {
6+
header "type-classification.h"
77
}
88

99
module MemberwiseInitializer {

test/Interop/Cxx/class/Inputs/loadable-types.h renamed to test/Interop/Cxx/class/Inputs/type-classification.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct StructWithSubobjectMoveAssignment {
8080
};
8181

8282
struct StructWithDestructor {
83-
~StructWithDestructor(){}
83+
~StructWithDestructor() {}
8484
};
8585

8686
struct StructWithInheritedDestructor : StructWithDestructor {};

test/Interop/Cxx/class/loadable-types-silgen.swift renamed to test/Interop/Cxx/class/type-classification-loadable-silgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This test checks that we classify C++ types as loadable and address-only
44
// correctly.
55

6-
import LoadableTypes
6+
import TypeClassification
77

88
// Tests for individual special members
99

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-sil %s | %FileCheck %s
2+
3+
import TypeClassification
4+
5+
// Make sure that "StructWithDestructor" is marked as non-trivial by checking for a
6+
// "destroy_addr".
7+
// CHECK-LABEL: @$s4main24testStructWithDestructoryyF
8+
// CHECK: [[AS:%.*]] = alloc_stack $StructWithDestructor
9+
// CHECK: destroy_addr [[AS]]
10+
// CHECK-LABEL: end sil function '$s4main24testStructWithDestructoryyF'
11+
public func testStructWithDestructor() {
12+
let d = StructWithDestructor()
13+
}
14+
15+
// Make sure that "HasMemberWithDestructor" is marked as non-trivial by checking
16+
// for a "destroy_addr".
17+
// CHECK-LABEL: @$s4main33testStructWithSubobjectDestructoryyF
18+
// CHECK: [[AS:%.*]] = alloc_stack $StructWithSubobjectDestructor
19+
// CHECK: destroy_addr [[AS]]
20+
// CHECK-LABEL: end sil function '$s4main33testStructWithSubobjectDestructoryyF'
21+
public func testStructWithSubobjectDestructor() {
22+
let d = StructWithSubobjectDestructor()
23+
}
24+
25+

0 commit comments

Comments
 (0)