1
1
2
- // RUN: %target-swift-emit-silgen -module-name objc_thunks -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-verbose-sil -swift-version 5 -access-notes %S/Inputs/objc_access_notes.accessnotes | %FileCheck %s
2
+ // RUN: %target-swift-emit-silgen -module-name objc_thunks -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-verbose-sil -swift-version 5 -access-notes %S/Inputs/objc_access_notes.accessnotes -verify | %FileCheck %s
3
+
4
+ // Verify that the access notes are necessary for the test to pass.
3
5
// RUN-X: not %target-swift-emit-silgen -module-name objc_thunks -Xllvm -sil-full-demangle -Xllvm -sil-print-debuginfo -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-verbose-sil -swift-version 5 | %FileCheck %s
4
6
5
7
// REQUIRES: objc_interop
@@ -8,6 +10,8 @@ import gizmo
8
10
import ansible
9
11
10
12
class Hoozit : Gizmo {
13
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
14
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
11
15
func typical( _ x: Int , y: Gizmo ) -> Gizmo { return y }
12
16
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC7typical_1ySo5GizmoCSi_AGtFTo : $@convention(objc_method) (Int, Gizmo, Hoozit) -> @autoreleased Gizmo {
13
17
// CHECK: bb0([[X:%.*]] : $Int, [[Y:%.*]] : @unowned $Gizmo, [[THIS:%.*]] : @unowned $Hoozit):
@@ -52,6 +56,8 @@ class Hoozit : Gizmo {
52
56
// CHECK-NEXT: }
53
57
54
58
// NS_RETURNS_RETAINED by family (-copy)
59
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
60
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
55
61
func copyFoo( ) -> Gizmo { return self }
56
62
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC7copyFooSo5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
57
63
// CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
@@ -66,6 +72,8 @@ class Hoozit : Gizmo {
66
72
// CHECK-NEXT: }
67
73
68
74
// NS_RETURNS_RETAINED by family (-mutableCopy)
75
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
76
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
69
77
func mutableCopyFoo( ) -> Gizmo { return self }
70
78
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC14mutableCopyFooSo5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
71
79
// CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
@@ -82,6 +90,8 @@ class Hoozit : Gizmo {
82
90
// NS_RETURNS_RETAINED by family (-copy). This is different from Swift's
83
91
// normal notion of CamelCase, but it's what Clang does, so we should match
84
92
// it.
93
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
94
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
85
95
func copy8( ) -> Gizmo { return self }
86
96
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC5copy8So5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
87
97
// CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
@@ -96,6 +106,8 @@ class Hoozit : Gizmo {
96
106
// CHECK-NEXT: }
97
107
98
108
// NS_RETURNS_RETAINED by family (-copy)
109
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
110
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
99
111
func makeDuplicate( ) -> Gizmo { return self }
100
112
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC13makeDuplicateSo5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo
101
113
// CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
@@ -111,6 +123,8 @@ class Hoozit : Gizmo {
111
123
112
124
// Override the normal family conventions to make this non-consuming and
113
125
// returning at +0.
126
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
127
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
114
128
func initFoo( ) -> Gizmo { return self }
115
129
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC7initFooSo5GizmoCyFTo : $@convention(objc_method) (Hoozit) -> @autoreleased Gizmo
116
130
// CHECK: bb0([[THIS:%.*]] : @unowned $Hoozit):
@@ -124,6 +138,8 @@ class Hoozit : Gizmo {
124
138
// CHECK-NEXT: return [[RES]]
125
139
// CHECK-NEXT: }
126
140
141
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
142
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
127
143
var typicalProperty : Gizmo
128
144
// -- getter
129
145
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC15typicalPropertySo5GizmoCvgTo : $@convention(objc_method) (Hoozit) -> @autoreleased Gizmo {
@@ -174,6 +190,8 @@ class Hoozit : Gizmo {
174
190
// CHECK: } // end sil function '$s11objc_thunks6HoozitC15typicalPropertySo5GizmoCvs'
175
191
176
192
// NS_RETURNS_RETAINED getter by family (-copy)
193
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
194
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
177
195
var copyProperty : Gizmo
178
196
// -- getter
179
197
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC12copyPropertySo5GizmoCvgTo : $@convention(objc_method) (Hoozit) -> @owned Gizmo {
@@ -221,6 +239,8 @@ class Hoozit : Gizmo {
221
239
// CHECK: destroy_value [[ARG1]]
222
240
// CHECK: } // end sil function '$s11objc_thunks6HoozitC12copyPropertySo5GizmoCvs'
223
241
242
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
243
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
224
244
var roProperty : Gizmo { return self }
225
245
// -- getter
226
246
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC10roPropertySo5GizmoCvgTo : $@convention(objc_method) (Hoozit) -> @autoreleased Gizmo {
@@ -238,6 +258,8 @@ class Hoozit : Gizmo {
238
258
// -- no setter
239
259
// CHECK-NOT: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC10roPropertySo5GizmoCvsTo
240
260
261
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
262
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
241
263
var rwProperty : Gizmo {
242
264
get {
243
265
return self
@@ -261,6 +283,8 @@ class Hoozit : Gizmo {
261
283
// CHECK-NEXT: return
262
284
// CHECK-NEXT: }
263
285
286
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
287
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
264
288
var copyRWProperty : Gizmo {
265
289
get {
266
290
return self
@@ -295,6 +319,8 @@ class Hoozit : Gizmo {
295
319
// CHECK-NEXT: return
296
320
// CHECK-NEXT: }
297
321
322
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
323
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
298
324
var initProperty : Gizmo
299
325
// -- getter
300
326
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC12initPropertySo5GizmoCvgTo : $@convention(objc_method) (Hoozit) -> @autoreleased Gizmo {
@@ -323,6 +349,8 @@ class Hoozit : Gizmo {
323
349
// CHECK-NEXT: return
324
350
// CHECK-NEXT: }
325
351
352
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this property}}
353
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
326
354
var propComputed : Gizmo {
327
355
// FIXME: Add a way to specify these names in an access note.
328
356
@objc ( initPropComputedGetter) get { return self }
@@ -379,6 +407,8 @@ class Hoozit : Gizmo {
379
407
}
380
408
381
409
// Subscript
410
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this subscript}}
411
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
382
412
subscript ( i: Int ) -> Hoozit {
383
413
// Getter
384
414
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitCyACSicigTo : $@convention(objc_method) (Int, Hoozit) -> @autoreleased Hoozit
@@ -424,6 +454,8 @@ class Wotsit<T> : Gizmo {
424
454
// CHECK-NEXT: return [[RESULT]] : $()
425
455
// CHECK-NEXT: }
426
456
func plain( ) { }
457
+ // expected-warning@-1 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
458
+ // expected-note@-2 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
427
459
428
460
func generic< U> ( _ x: U ) { }
429
461
@@ -470,14 +502,20 @@ class Wotsit<T> : Gizmo {
470
502
extension Hoozit {
471
503
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC3intACSi_tcfcTo : $@convention(objc_method) (Int, @owned Hoozit) -> @owned Hoozit
472
504
convenience init ( int i: Int ) { self . init ( bellsOn: i) }
505
+ // expected-warning@-1 {{access note for fancy test suite adds attribute 'objc' to this initializer}}
506
+ // expected-note@-2 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
507
+ // expected-warning@-3 {{access note for fancy test suite adds modifier 'dynamic' to this initializer}}
508
+ // expected-note@-4 {{add modifier explicitly to silence this warning}} {{3-3=dynamic }}
473
509
474
510
// CHECK-LABEL: sil hidden [ossa] @$s11objc_thunks6HoozitC6doubleACSd_tcfC : $@convention(method) (Double, @thick Hoozit.Type) -> @owned Hoozit
475
511
convenience init ( double d: Double ) {
476
- var x = X ( )
512
+ var x = X ( ) // expected-warning {{initialization of variable 'x' was never used}}
477
513
self . init ( int: Int ( d) )
478
514
other ( )
479
515
}
480
516
517
+ // expected-warning@+2 {{access note for fancy test suite adds attribute 'objc' to this instance method}}
518
+ // expected-note@+1 {{add attribute explicitly to silence this warning}} {{3-3=@objc }}
481
519
func foof( ) { }
482
520
// CHECK-LABEL: sil hidden [thunk] [ossa] @$s11objc_thunks6HoozitC4foofyyFTo : $@convention(objc_method) (Hoozit) -> () {
483
521
0 commit comments