Skip to content

Commit 6ebd2a7

Browse files
authored
Merge pull request #32658 from zoecarver/cxx/test/no-arg-const
2 parents 5f6f46f + 4b14487 commit 6ebd2a7

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ module MemberVariables {
2121
module ProtocolConformance {
2222
header "protocol-conformance.h"
2323
}
24+
25+
module SynthesizedInitializers {
26+
header "synthesized-initializers.h"
27+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct EmptyStruct {};
2+
3+
struct IntBox {
4+
int x;
5+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-silgen %s | %FileCheck %s
2+
3+
import SynthesizedInitializers
4+
5+
// CHECK-LABEL: sil shared [transparent] [serializable] [ossa] @$sSo11EmptyStructVABycfC : $@convention(method) (@thin EmptyStruct.Type) -> EmptyStruct
6+
// CHECK: bb0(%{{[0-9]+}} : $@thin EmptyStruct.Type):
7+
// CHECK-NEXT: [[BOX:%.*]] = alloc_box ${ var EmptyStruct }
8+
// CHECK-NEXT: [[UNINIT:%.*]] = mark_uninitialized [rootself] [[BOX]] : ${ var EmptyStruct }
9+
// CHECK-NEXT: [[PTR:%.*]] = project_box [[UNINIT]] : ${ var EmptyStruct }, 0
10+
// CHECK-NEXT: [[OBJ:%.*]] = builtin "zeroInitializer"<EmptyStruct>() : $EmptyStruct
11+
// CHECK-NEXT: [[PA:%.*]] = begin_access [modify] [unknown] [[PTR]] : $*EmptyStruct
12+
// CHECK-NEXT: assign [[OBJ]] to [[PA]]
13+
// CHECK-NEXT: end_access [[PA]]
14+
// CHECK-NEXT: [[OUT:%.*]] = load [trivial] [[PTR]]
15+
// CHECK-NEXT: destroy_value [[UNINIT]]
16+
// CHECK-NEXT: return [[OUT]]
17+
// CHECK-LABEL: end sil function '$sSo11EmptyStructVABycfC'
18+
public func emptyTypeNoArgInit() {
19+
let e = EmptyStruct()
20+
}
21+
22+
// CHECK-LABEL: sil shared [transparent] [serializable] [ossa] @$sSo6IntBoxVABycfC : $@convention(method) (@thin IntBox.Type) -> IntBox
23+
// CHECK: bb0(%{{[0-9]+}} : $@thin IntBox.Type):
24+
// CHECK-NEXT: [[BOX:%.*]] = alloc_box ${ var IntBox }
25+
// CHECK-NEXT: [[UNINIT:%.*]] = mark_uninitialized [rootself] [[BOX]] : ${ var IntBox }
26+
// CHECK-NEXT: [[PTR:%.*]] = project_box [[UNINIT]] : ${ var IntBox }, 0
27+
// CHECK-NEXT: [[OBJ:%.*]] = builtin "zeroInitializer"<IntBox>() : $IntBox
28+
// CHECK-NEXT: [[PA:%.*]] = begin_access [modify] [unknown] [[PTR]] : $*IntBox
29+
// CHECK-NEXT: assign [[OBJ]] to [[PA]]
30+
// CHECK-NEXT: end_access [[PA]]
31+
// CHECK-NEXT: [[OUT:%.*]] = load [trivial] [[PTR]]
32+
// CHECK-NEXT: destroy_value [[UNINIT]]
33+
// CHECK-NEXT: return [[OUT]]
34+
// CHECK-LABEL: end sil function '$sSo6IntBoxVABycfC'
35+
public func singleMemberTypeNoArgInit() {
36+
let i = IntBox()
37+
}
38+
39+
// CHECK-LABEL: sil shared [transparent] [serializable] [ossa] @$sSo6IntBoxV1xABs5Int32V_tcfC : $@convention(method) (Int32, @thin IntBox.Type) -> IntBox
40+
// CHECK: bb0([[I:%[0-9]+]] : $Int32, %{{[0-9]+}} : $@thin IntBox.Type):
41+
// CHECK-NEXT: [[S:%.*]] = struct $IntBox ([[I]] : $Int32)
42+
// CHECK-NEXT: return [[S]]
43+
// CHECK-LABEL: end sil function '$sSo6IntBoxV1xABs5Int32V_tcfC'
44+
public func singleMemberTypeValueInit() {
45+
let i = IntBox(x: 42)
46+
}

0 commit comments

Comments
 (0)