Skip to content

Commit d9acaf3

Browse files
committed
[cxx-interop] Merge synthesized initializer tests into "constructors-silgen".
We no longer synthesize initializers for C++ types so this name no longer makes sense.
1 parent 1d3b051 commit d9acaf3

File tree

4 files changed

+56
-53
lines changed

4 files changed

+56
-53
lines changed

test/Interop/Cxx/class/Inputs/constructors.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ struct HasVirtualBase : public virtual Base {
3737
HasVirtualBase(ArgType Arg) {}
3838
int i;
3939
};
40+
41+
struct EmptyStruct {};
42+
43+
struct IntWrapper {
44+
int x;
45+
};

test/Interop/Cxx/class/Inputs/synthesized-initializers.h

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
1-
// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-sil %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -I %S/Inputs -enable-cxx-interop -emit-silgen %s | %FileCheck %s
22

33
import Constructors
44

55
// The most important thing to test here is that the constructor result is
66
// returned with an @out attribute.
7+
// CHECK-LABEL: sil [ossa] @$s4main24testConstructorWithParamyyF : $@convention(thin) () -> ()
78
// CHECK: [[VAR:%[0-9]+]] = alloc_stack $ConstructorWithParam
8-
// CHECK: [[LITERAL:%[0-9]+]] = integer_literal $Builtin.Int32, 42
9-
// CHECK: [[INT:%[0-9]+]] = struct $Int32 ([[LITERAL]] : $Builtin.Int32)
9+
// CHECK: [[LITERAL:%[0-9]+]] = integer_literal $Builtin.IntLiteral, 42
10+
// CHECK: [[INT:%[0-9]+]] = apply %{{[0-9]+}}([[LITERAL]], %{{[0-9]+}})
1011
// CHECK: [[FUNC:%[0-9]+]] = function_ref @{{_ZN20ConstructorWithParamC1Ei|\?\?0ConstructorWithParam@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out ConstructorWithParam
1112
// CHECK: %{{[0-9]+}} = apply [[FUNC]]([[VAR]], [[INT]]) : $@convention(c) (Int32) -> @out ConstructorWithParam
12-
let _ = ConstructorWithParam(42)
13+
// CHECK-LABEL: end sil function '$s4main24testConstructorWithParamyyF'
14+
15+
// CHECK-LABEL: sil [clang ConstructorWithParam.init] @{{_ZN20ConstructorWithParamC1Ei|\?\?0ConstructorWithParam@@QEAA@H@Z}} : $@convention(c) (Int32) -> @out ConstructorWithParam
16+
public func testConstructorWithParam() {
17+
let c = ConstructorWithParam(42)
18+
}
19+
20+
// CHECK-LABEL: sil [ossa] @$s4main18emptyTypeNoArgInityyF : $@convention(thin) () -> ()
21+
// CHECK: [[AS:%.*]] = alloc_stack $EmptyStruct
22+
// CHECK: [[FN:%.*]] = function_ref @{{_ZN11EmptyStructC1Ev|\?\?0EmptyStruct@@QEAA@XZ}} : $@convention(c) () -> @out EmptyStruct
23+
// CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out EmptyStruct
24+
// CHECK-LABEL: end sil function '$s4main18emptyTypeNoArgInityyF'
25+
26+
// CHECL-LABEL: sil [clang EmptyStruct.init] @{{_ZN11EmptyStructC1Ev|\?\?0EmptyStruct@@QEAA@XZ}} : $@convention(c) () -> @out EmptyStruct
27+
public func emptyTypeNoArgInit() {
28+
let e = EmptyStruct()
29+
}
30+
31+
// CHECK-LABEL: sil [ossa] @$s4main25singleMemberTypeNoArgInityyF : $@convention(thin) () -> ()
32+
// CHECK: [[AS:%.*]] = alloc_stack $IntWrapper
33+
// CHECK: [[FN:%.*]] = function_ref @{{_ZN10IntWrapperC1Ev|\?\?0IntWrapper@@QEAA@XZ}} : $@convention(c) () -> @out IntWrapper
34+
// CHECK: apply [[FN]]([[AS]]) : $@convention(c) () -> @out IntWrapper
35+
// CHECK-LABEL: end sil function '$s4main25singleMemberTypeNoArgInityyF'
36+
37+
//CHECK-LABEL: sil [clang IntWrapper.init] @{{_ZN10IntWrapperC1Ev|\?\?0IntWrapper@@QEAA@XZ}} : $@convention(c) () -> @out IntWrapper
38+
public func singleMemberTypeNoArgInit() {
39+
let i = IntWrapper()
40+
}
41+
42+
// CHECK-LABEL: sil shared [transparent] [serializable] [ossa] @$sSo10IntWrapperV1xABs5Int32V_tcfC : $@convention(method) (Int32, @thin IntWrapper.Type) -> IntWrapper
43+
// CHECK: bb0([[I:%[0-9]+]] : $Int32, %{{[0-9]+}} : $@thin IntWrapper.Type):
44+
// CHECK-NEXT: [[S:%.*]] = struct $IntWrapper ([[I]] : $Int32)
45+
// CHECK-NEXT: return [[S]]
46+
// CHECK-LABEL: end sil function '$sSo10IntWrapperV1xABs5Int32V_tcfC'
47+
public func singleMemberTypeValueInit() {
48+
let i = IntWrapper(x: 42)
49+
}
50+
51+
// CHECK-LABEL: sil shared [transparent] [serializable] [ossa] @$sSo25DefaultConstructorDeletedV1aABSpys5Int32VG_tcfC : $@convention(method) (UnsafeMutablePointer<Int32>, @thin DefaultConstructorDeleted.Type) -> DefaultConstructorDeleted
52+
// CHECK: bb0([[A:%.*]] : $UnsafeMutablePointer<Int32>
53+
// CHECK-NEXT: [[OUT:%.*]] = struct $DefaultConstructorDeleted ([[A]] : $UnsafeMutablePointer<Int32>)
54+
// CHECK-NEXT: return [[OUT]] : $DefaultConstructorDeleted
55+
// CHECK-LABEL: end sil function '$sSo25DefaultConstructorDeletedV1aABSpys5Int32VG_tcfC'
56+
public func deletedConstructor(a: UnsafeMutablePointer<Int32>) {
57+
let deletedExplicitly = DefaultConstructorDeleted(a: a)
58+
}

test/Interop/Cxx/class/synthesized-initializers-silgen.swift

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)