Skip to content

Commit 92d2c23

Browse files
committed
[Tests] Fix and refactor skip-function-bodies.swift
1 parent fdff522 commit 92d2c23

File tree

1 file changed

+41
-66
lines changed

1 file changed

+41
-66
lines changed

test/Frontend/skip-function-bodies.swift

Lines changed: 41 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
// WARNING: module 'SwiftOnoneSupport' cannot be built with -experimental-skip-non-inlinable-function-bodies; this option has been automatically disabled
1414

1515
// Check skipped bodies are neither typechecked nor SILgen'd
16-
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -experimental-skip-non-inlinable-function-bodies -debug-forbid-typecheck-prefix INLINENOTYPECHECK %s -o %t/Skip.noninlinable.sil
17-
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -O -experimental-skip-all-function-bodies -debug-forbid-typecheck-prefix ALLNOTYPECHECK %s -o %t/Skip.all.sil
18-
// %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY < %t/Skip.noninlinable.sil
19-
// %FileCheck %s --check-prefixes CHECK,CHECK-ALL-ONLY < %t/Skip.all.sil
16+
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -experimental-skip-non-inlinable-function-bodies -debug-forbid-typecheck-prefix NEVERTYPECHECK -debug-forbid-typecheck-prefix INLINENOTYPECHECK %s -o %t/Skip.noninlinable.sil
17+
// RUN: %target-swift-frontend -emit-sil -emit-sorted-sil -experimental-skip-all-function-bodies -debug-forbid-typecheck-prefix NEVERTYPECHECK -debug-forbid-typecheck-prefix ALLNOTYPECHECK %s -o %t/Skip.all.sil
18+
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY,CHECK-NONINLINE-SIL < %t/Skip.noninlinable.sil
19+
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-ALL-ONLY < %t/Skip.all.sil
2020

2121
// Emit the module interface and check it against the same set of strings.
2222
// RUN: %target-swift-frontend -typecheck %s -enable-library-evolution -emit-module-interface-path %t/Skip.noninlinable.swiftinterface -experimental-skip-non-inlinable-function-bodies
23-
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY < %t/Skip.noninlinable.swiftinterface
23+
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY,CHECK-NONINLINE-TEXTUAL < %t/Skip.noninlinable.swiftinterface
2424
// RUN: %target-swift-frontend -typecheck %s -enable-library-evolution -emit-module-interface-path %t/Skip.all.swiftinterface -experimental-skip-all-function-bodies
25-
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-ALL-ONLY < %t/Skip.all.swiftinterface
25+
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-ALL-ONLY,CHECK-NONINLINE-TEXTUAL < %t/Skip.all.swiftinterface
2626

2727
// Emit the module interface normally, it should be the same as when skipping
2828
// non-inlinable.
2929
// RUN: %target-swift-frontend -typecheck %s -enable-library-evolution -emit-module-interface-path %t/Skip.swiftinterface
30-
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY < %t/Skip.swiftinterface
30+
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-NONINLINE-ONLY,CHECK-NONINLINE-TEXTUAL < %t/Skip.swiftinterface
3131
// RUN: diff -u %t/Skip.noninlinable.swiftinterface %t/Skip.swiftinterface
3232

3333
@usableFromInline
@@ -58,16 +58,14 @@ public class InlinableDeinit {
5858
@_fixed_layout
5959
public class InlineAlwaysDeinit {
6060
@inline(__always) deinit {
61-
let ALLNOTYPECHECK_local = 1
62-
let INLINENOTYPECHECK_local = 1
61+
let NEVERTYPECHECK_local = 1
6362
_blackHole("@inline(__always) deinit body") // CHECK-NOT: "@inline(__always) deinit body"
6463
}
6564
}
6665

6766
public class NormalDeinit {
6867
deinit {
69-
let ALLNOTYPECHECK_local = 1
70-
let INLINENOTYPECHECK = 1
68+
let NEVERTYPECHECK_local = 1
7169
_blackHole("regular deinit body") // CHECK-NOT: "regular deinit body"
7270
}
7371
}
@@ -80,52 +78,44 @@ public class NormalDeinit {
8078
}
8179

8280
@inline(__always) public func inlineAlwaysFunc() {
83-
let ALLNOTYPECHECK_local = 1
84-
let INLINENOTYPECHECK_local = 1
81+
let NEVERTYPECHECK_local = 1
8582
_blackHole("@inline(__always) func body") // CHECK-NOT: "@inline(__always) func body"
8683
}
8784

8885
func internalFunc() {
89-
let ALLNOTYPECHECK_local = 1
90-
let INLINENOTYPECHECK_local = 1
86+
let NEVERTYPECHECK_local = 1
9187
_blackHole("internal func body") // CHECK-NOT: "internal func body"
9288
}
9389

9490
public func publicFunc() {
95-
let ALLNOTYPECHECK_local = 1
96-
let INLINENOTYPECHECK_local = 1
91+
let NEVERTYPECHECK_local = 1
9792
_blackHole("public func body") // CHECK-NOT: "public func body"
9893
}
9994

10095
private func privateFunc() {
101-
let ALLNOTYPECHECK_local = 1
102-
let INLINENOTYPECHECK_local = 1
96+
let NEVERTYPECHECK_local = 1
10397
_blackHole("private func body") // CHECK-NOT: "private func body"
10498
}
10599

106100
@inline(__always) public func inlineAlwaysLocalTypeFunc() {
107-
let ALLNOTYPECHECK_outerLocal = 1
108-
let INLINENOTYPECHECK_outerLocal = 1
101+
let NEVERTYPECHECK_outerLocal = 1
109102

110103
typealias InlineAlwaysLocalType = Int
111104
_blackHole("@inline(__always) func body with local type") // CHECK-NOT: "@inline(__always) func body with local type"
112105
func takesInlineAlwaysLocalType(_ x: InlineAlwaysLocalType) {
113-
let ALLNOTYPECHECK_innerLocal = 1
114-
let INLINENOTYPECHECK_innerLocal = 1
106+
let NEVERTYPECHECK_innerLocal = 1
115107
_blackHole("nested func body inside @inline(__always) func body taking local type") // CHECK-NOT: "nested func body inside @inline(__always) func body taking local type"
116108
}
117109
takesInlineAlwaysLocalType(0)
118110
}
119111

120112
public func publicLocalTypeFunc() {
121-
let ALLNOTYPECHECK_outerLocal = 1
122-
let INLINENOTYPECHECK_outerLocal = 1
113+
let NEVERTYPECHECK_outerLocal = 1
123114

124115
typealias LocalType = Int
125116
_blackHole("public func body with local type") // CHECK-NOT: "public func body with local type"
126117
func takesLocalType(_ x: LocalType) {
127-
let ALLNOTYPECHECK_innerLocal = 1
128-
let INLINENOTYPECHECK_innerLocal = 1
118+
let NEVERTYPECHECK_innerLocal = 1
129119
_blackHole("nested func body inside public func body taking local type") // CHECK-NOT: "nested func body inside public func body taking local type"
130120
}
131121
takesLocalType(0)
@@ -206,8 +196,7 @@ public struct Struct {
206196

207197
@inline(__always)
208198
public func inlineAlwaysFunc() {
209-
let ALLNOTYPECHECK_local = 1
210-
let INLINENOTYPECHECK_local = 1
199+
let NEVERTYPECHECK_local = 1
211200
_blackHole("@inline(__always) method body") // CHECK-NOT: "@inline(__always) method body"
212201
}
213202

@@ -236,13 +225,6 @@ public struct Struct {
236225
}
237226
}
238227

239-
public var didSetVar: Int = 1 {
240-
didSet {
241-
// Body typechecked regardless
242-
_blackHole("didSet body") // CHECK-NOT: "didSet body"
243-
}
244-
}
245-
246228
@_transparent
247229
public func transparentFunc() {
248230
let ALLNOTYPECHECK_local = 1
@@ -252,20 +234,17 @@ public struct Struct {
252234
}
253235

254236
func internalFunc() {
255-
let ALLNOTYPECHECK_local = 1
256-
let INLINENOTYPECHECK_local = 1
237+
let NEVERTYPECHECK_local = 1
257238
_blackHole("internal method body") // CHECK-NOT: "internal method body"
258239
}
259240

260241
public func publicFunc() {
261-
let ALLNOTYPECHECK_local = 1
262-
let INLINENOTYPECHECK_local = 1
242+
let NEVERTYPECHECK_local = 1
263243
_blackHole("public method body") // CHECK-NOT: "public method body"
264244
}
265245

266246
private func privateFunc() {
267-
let ALLNOTYPECHECK_local = 1
268-
let INLINENOTYPECHECK_local = 1
247+
let NEVERTYPECHECK_local = 1
269248
_blackHole("private method body") // CHECK-NOT: "private method body"
270249
}
271250

@@ -276,6 +255,14 @@ public struct Struct {
276255
// CHECK-ALL-ONLY-NOT: "@_transparent init body"
277256
}
278257

258+
public var didSetVar: Int = 1 {
259+
didSet {
260+
// Body typechecked regardless
261+
_blackHole("didSet body") // CHECK-NONINLINE-SIL: "didSet body"
262+
// CHECK-NONINLINE-TEXTUAL-NOT: "didSet body"
263+
}
264+
}
265+
279266
@inlinable public init() {
280267
let ALLNOTYPECHECK_local = 1
281268
_blackHole("@inlinable init body")
@@ -284,26 +271,22 @@ public struct Struct {
284271
}
285272

286273
@inline(__always) public init(a: Int) {
287-
let ALLNOTYPECHECK_local = 1
288-
let INLINENOTYPECHECK_local = 1
274+
let NEVERTYPECHECK_local = 1
289275
_blackHole("@inline(__always) init body") // CHECK-NOT: "@inline(__always) init body"
290276
}
291277

292278
init(c: Int) {
293-
let ALLNOTYPECHECK_local = 1
294-
let INLINENOTYPECHECK_local = 1
279+
let NEVERTYPECHECK_local = 1
295280
_blackHole("internal init body") // CHECK-NOT: "internal init body"
296281
}
297282

298283
public init(d: Int) {
299-
let ALLNOTYPECHECK_local = 1
300-
let INLINENOTYPECHECK_local = 1
284+
let NEVERTYPECHECK_local = 1
301285
_blackHole("public init body") // CHECK-NOT: "public init body"
302286
}
303287

304288
private init(e: Int) {
305-
let ALLNOTYPECHECK_local = 1
306-
let INLINENOTYPECHECK_local = 1
289+
let NEVERTYPECHECK_local = 1
307290
_blackHole("private init body") // CHECK-NOT: "private init body"
308291
}
309292

@@ -316,8 +299,7 @@ public struct Struct {
316299
}
317300

318301
@inline(__always) public subscript(a: Int, b: Int) -> Int {
319-
let ALLNOTYPECHECK_local = 1
320-
let INLINENOTYPECHECK_local = 1
302+
let NEVERTYPECHECK_local = 1
321303
_blackHole("@inline(__always) subscript getter") // CHECK-NOT: "@inline(__always) subscript getter"
322304
return 0
323305
}
@@ -333,54 +315,47 @@ public struct Struct {
333315
}
334316

335317
subscript(a: Int, b: Int, c: Int, d: Int) -> Int {
336-
let ALLNOTYPECHECK_local = 1
337-
let INLINENOTYPECHECK_local = 1
318+
let NEVERTYPECHECK_local = 1
338319
_blackHole("internal subscript getter") // CHECK-NOT: "internal subscript getter"
339320
return 0
340321
}
341322

342323
public subscript(a: Int, b: Int, c: Int, d: Int, e: Int) -> Int {
343-
let ALLNOTYPECHECK_local = 1
344-
let INLINENOTYPECHECK_local = 1
324+
let NEVERTYPECHECK_local = 1
345325
_blackHole("public subscript getter") // CHECK-NOT: "public subscript getter"
346326
return 0
347327
}
348328

349329
private subscript(e: Int) -> Int {
350-
let ALLNOTYPECHECK_local = 1
351-
let INLINENOTYPECHECK_local = 1
330+
let NEVERTYPECHECK_local = 1
352331
_blackHole("private subscript getter") // CHECK-NOT: "private subscript getter"
353332
return 0
354333
}
355334

356335
@inline(__always) public var inlineAlwaysVar: Int {
357-
let ALLNOTYPECHECK_local = 1
358-
let INLINENOTYPECHECK_local = 1
336+
let NEVERTYPECHECK_local = 1
359337
_blackHole("@inline(__always) getter body") // CHECK-NOT: "@inline(__always) getter body"
360338
return 0
361339
}
362340

363341
public var publicVar: Int {
364-
let ALLNOTYPECHECK_local = 1
365-
let INLINENOTYPECHECK_local = 1
342+
let NEVERTYPECHECK_local = 1
366343
_blackHole("public getter body") // CHECK-NOT: "public getter body"
367344
return 0
368345
}
369346

370347
public var inlineAlwaysSetter: Int {
371348
get { 0 }
372349
@inline(__always) set {
373-
let ALLNOTYPECHECK_local = 1
374-
let INLINENOTYPECHECK_local = 1
350+
let NEVERTYPECHECK_local = 1
375351
_blackHole("@inline(__always) setter body") // CHECK-NOT: "@inline(__always) setter body"
376352
}
377353
}
378354

379355
public var regularSetter: Int {
380356
get { 0 }
381357
set {
382-
let ALLNOTYPECHECK_local = 1
383-
let INLINENOTYPECHECK_local = 1
358+
let NEVERTYPECHECK_local = 1
384359
_blackHole("@inline(__always) setter body") // CHECK-NOT: "regular setter body"
385360
}
386361
}

0 commit comments

Comments
 (0)