-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathinherits_ObjCClasses.swift
188 lines (143 loc) · 7.04 KB
/
inherits_ObjCClasses.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// RUN: %empty-directory(%t)
// RUN: %clang %target-cc-options -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o
// RUN: %target-build-swift -I %S/Inputs/ObjCClasses/ -lswiftSwiftReflectionTest %t/ObjCClasses.o %s -o %t/inherits_ObjCClasses
// RUN: %target-codesign %t/inherits_ObjCClasses
// RUN: %target-run %target-swift-reflection-test %t/inherits_ObjCClasses | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
// REQUIRES: objc_interop
// REQUIRES: executable_test
// REQUIRES: reflection_test_support
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: asan
import simd
import ObjCClasses
import SwiftReflectionTest
//// FirstClass -- base class, has one word-sized ivar
// Variant A: 16 byte alignment
class FirstClassA : FirstClass {
var xx: int4 = [1,2,3,4]
}
let firstClassA = FirstClassA()
reflect(object: firstClassA)
// CHECK-64: Type reference:
// CHECK-64: (class inherits_ObjCClasses.FirstClassA)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=32 alignment=16 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=xx offset=16
// CHECK-64: (struct size=16 alignment=16 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class inherits_ObjCClasses.FirstClassA)
// CHECK-32: Type info:
// CHECK-32-NEXT: (class_instance size=32 alignment=16 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=xx offset=16
// CHECK-32-NEXT: (struct size=16 alignment=16 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// Variant B: word size alignment
class FirstClassB : FirstClass {
var zz: Int = 0
}
let firstClassB = FirstClassB()
reflect(object: firstClassB)
// CHECK-64: Type reference:
// CHECK-64: (class inherits_ObjCClasses.FirstClassB)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=zz offset=16
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class inherits_ObjCClasses.FirstClassB)
// CHECK-32: Type info:
// CHECK-32-NEXT: (class_instance size=12 alignment=4 stride=12 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=zz offset=8
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))
//// SecondClass -- base class, has two word-sized ivars
// Variant A: 16 byte alignment
class SecondClassA : SecondClass {
var xx: int4 = [1,2,3,4]
}
let secondClassA = SecondClassA()
reflect(object: secondClassA)
// CHECK-64: Type reference:
// CHECK-64: (class inherits_ObjCClasses.SecondClassA)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=48 alignment=16 stride=48 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=xx offset=32
// CHECK-64: (struct size=16 alignment=16 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class inherits_ObjCClasses.SecondClassA)
// CHECK-32: Type info:
// CHECK-32-NEXT: (class_instance size=32 alignment=16 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=xx offset=16
// CHECK-32-NEXT: (struct size=16 alignment=16 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// Variant B: word size alignment
class SecondClassB : SecondClass {
var zz: Int = 0
}
let secondClassB = SecondClassB()
reflect(object: secondClassB)
// CHECK-64: Type reference:
// CHECK-64: (class inherits_ObjCClasses.SecondClassB)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=32 alignment=8 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=zz offset=24
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class inherits_ObjCClasses.SecondClassB)
// CHECK-32: Type info:
// CHECK-32-NEXT: (class_instance size=16 alignment=4 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=zz offset=12
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))
//// ThirdClass -- base class, has three word-sized ivars
// Variant A: 16 byte alignment
class ThirdClassA : ThirdClass {
var xx: int4 = [1,2,3,4]
}
let thirdClassA = ThirdClassA()
reflect(object: thirdClassA)
// CHECK-64: Type reference:
// CHECK-64: (class inherits_ObjCClasses.ThirdClassA)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=48 alignment=16 stride=48 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=xx offset=32
// CHECK-64: (struct size=16 alignment=16 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class inherits_ObjCClasses.ThirdClassA)
// CHECK-32: Type info:
// CHECK-32-NEXT: (class_instance size=32 alignment=16 stride=32 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=xx offset=16
// CHECK-32-NEXT: (struct size=16 alignment=16 stride=16 num_extra_inhabitants=0 bitwise_takable=1
// Variant B: word size alignment
class ThirdClassB : ThirdClass {
var zz: Int = 0
}
let thirdClassB = ThirdClassB()
reflect(object: thirdClassB)
// CHECK-64: Type reference:
// CHECK-64: (class inherits_ObjCClasses.ThirdClassB)
// CHECK-64: Type info:
// CHECK-64: (class_instance size=40 alignment=8 stride=40 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=zz offset=32
// CHECK-64: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-64: (field name=_value offset=0
// CHECK-64: (builtin size=8 alignment=8 stride=8 num_extra_inhabitants=0 bitwise_takable=1)))))
// CHECK-32: Reflecting an object.
// CHECK-32: Type reference:
// CHECK-32: (class inherits_ObjCClasses.ThirdClassB)
// CHECK-32: Type info:
// CHECK-32-NEXT: (class_instance size=20 alignment=4 stride=20 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=zz offset=16
// CHECK-32-NEXT: (struct size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1
// CHECK-32-NEXT: (field name=_value offset=0
// CHECK-32-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)))))
doneReflecting()