1
1
// RUN: rm -rf %t && mkdir -p %t
2
- // RUN: %target-swift-frontend -emit-module -o %t -module-name Lib -I %S/Inputs/custom-modules %s
2
+ // RUN: %target-swift-frontend -emit-sil -o - -emit-module-path %t/Lib.swiftmodule -module-name Lib -I %S/Inputs/custom-modules %s | %FileCheck -check-prefix CHECK-VTABLE %s
3
3
4
4
// RUN: %target-swift-ide-test -source-filename=x -print-module -module-to-print Lib -I %t -I %S/Inputs/custom-modules | %FileCheck %s
5
5
9
9
10
10
// RUN: %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules -Xcc -DBAD -DTEST -enable-experimental-deserialization-recovery -DVERIFY %s -verify
11
11
// RUN: %target-swift-frontend -emit-silgen -I %t -I %S/Inputs/custom-modules -Xcc -DBAD -DTEST -enable-experimental-deserialization-recovery %s | %FileCheck -check-prefix CHECK-SIL %s
12
+ // RUN: %target-swift-frontend -emit-ir -I %t -I %S/Inputs/custom-modules -Xcc -DBAD -DTEST -enable-experimental-deserialization-recovery %s | %FileCheck -check-prefix CHECK-IR %s
12
13
13
14
#if TEST
14
15
@@ -24,6 +25,16 @@ func testSymbols() {
24
25
_ = Lib . usesAssoc
25
26
} // CHECK-SIL: end sil function '_T08typedefs11testSymbolsyyF'
26
27
28
+ // CHECK-IR-LABEL: define{{.*}} void @_T08typedefs18testVTableBuildingy3Lib4UserC4user_tF
29
+ public func testVTableBuilding( user: User ) {
30
+ // The important thing in this CHECK line is the "i64 23", which is the offset
31
+ // for the vtable slot for 'lastMethod()'. If the layout here
32
+ // changes, please check that offset 23 is still correct.
33
+ // CHECK-IR-NOT: ret
34
+ // CHECK-IR: getelementptr inbounds void (%T3Lib4UserC*)*, void (%T3Lib4UserC*)** %{{[0-9]+}}, i64 23
35
+ _ = user. lastMethod ( )
36
+ } // CHECK-IR: ret void
37
+
27
38
#if VERIFY
28
39
let _: String = useAssoc ( ImportedType . self) // expected-error {{cannot convert call result type '_.Assoc?' to expected type 'String'}}
29
40
let _: Bool ? = useAssoc ( ImportedType . self) // expected-error {{cannot convert value of type 'Int32?' to specified type 'Bool?'}}
@@ -93,12 +104,34 @@ open class User {
93
104
94
105
// CHECK: required init(wrappedRequired: WrappedInt)
95
106
// CHECK-RECOVERY: /* placeholder for init(wrappedRequired:) */
96
- // CHECK-RECOVERY: /* placeholder for init(wrappedRequired:) */
97
107
public required init ( wrappedRequired: WrappedInt ) { }
108
+
109
+ public func lastMethod( ) { }
98
110
}
99
111
// CHECK: {{^}$}}
100
112
// CHECK-RECOVERY: {{^}$}}
101
113
114
+ // This is mostly to check when changes are necessary for the CHECK-IR lines
115
+ // above.
116
+ // CHECK-VTABLE-LABEL: sil_vtable User {
117
+ // (8 words of normal class metadata)
118
+ // 9 CHECK-VTABLE-NEXT: #User.unwrappedProp!getter.1:
119
+ // 10 CHECK-VTABLE-NEXT: #User.unwrappedProp!setter.1:
120
+ // 11 CHECK-VTABLE-NEXT: #User.unwrappedProp!materializeForSet.1:
121
+ // 12 CHECK-VTABLE-NEXT: #User.wrappedProp!getter.1:
122
+ // 13 CHECK-VTABLE-NEXT: #User.wrappedProp!setter.1:
123
+ // 14 CHECK-VTABLE-NEXT: #User.wrappedProp!materializeForSet.1:
124
+ // 15 CHECK-VTABLE-NEXT: #User.returnsUnwrappedMethod!1:
125
+ // 16 CHECK-VTABLE-NEXT: #User.returnsWrappedMethod!1:
126
+ // 17 CHECK-VTABLE-NEXT: #User.subscript!getter.1:
127
+ // 18 CHECK-VTABLE-NEXT: #User.init!initializer.1:
128
+ // 19 CHECK-VTABLE-NEXT: #User.init!initializer.1:
129
+ // 20 CHECK-VTABLE-NEXT: #User.init!initializer.1:
130
+ // 21 CHECK-VTABLE-NEXT: #User.init!allocator.1:
131
+ // 22 CHECK-VTABLE-NEXT: #User.init!initializer.1:
132
+ // 23 CHECK-VTABLE-NEXT: #User.lastMethod!1:
133
+ // CHECK-VTABLE: }
134
+
102
135
103
136
// CHECK-LABEL: class UserConvenience
104
137
// CHECK-RECOVERY-LABEL: class UserConvenience
0 commit comments