Skip to content

Commit ea3e02b

Browse files
author
Harlan Haskins
committed
[ParseableInterface] Test accessor printing with @_hasStorage
1 parent a20c31a commit ea3e02b

File tree

2 files changed

+113
-9
lines changed

2 files changed

+113
-9
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.swiftinterface %s
4+
// RUN: %FileCheck %s < %t.swiftinterface --check-prefix CHECK --check-prefix COMMON
5+
6+
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t-resilient.swiftinterface -enable-resilience %s
7+
// RUN: %FileCheck %s < %t-resilient.swiftinterface --check-prefix RESILIENT --check-prefix COMMON
8+
9+
// RUN: %target-swift-frontend -emit-module -o %t/Test.swiftmodule %t.swiftinterface -disable-objc-attr-requires-foundation-module
10+
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/Test.swiftmodule -module-name Test -emit-parseable-module-interface-path - | %FileCheck %s --check-prefix CHECK --check-prefix COMMON
11+
12+
// RUN: %target-swift-frontend -emit-module -o %t/TestResilient.swiftmodule -enable-resilience %t-resilient.swiftinterface -disable-objc-attr-requires-foundation-module
13+
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules %t/TestResilient.swiftmodule -module-name TestResilient -enable-resilience -emit-parseable-module-interface-path - | %FileCheck %s --check-prefix RESILIENT --check-prefix COMMON
14+
15+
// COMMON: public struct HasStoredProperties {
16+
public struct HasStoredProperties {
17+
// COMMON: public var computedGetter: [[INT:.*Int]] {
18+
// COMMON-NEXT: get
19+
// COMMON-NEXT: }
20+
public var computedGetter: Int { return 3 }
21+
22+
// COMMON: public var computedGetSet: [[INT]] {
23+
// COMMON-NEXT: get
24+
// COMMON-NEXT: set
25+
// COMMON-NEXT: }
26+
public var computedGetSet: Int {
27+
get { return 3 }
28+
set {}
29+
}
30+
31+
// COMMON: public let simpleStoredImmutable: [[INT]]{{$}}
32+
public let simpleStoredImmutable: Int
33+
34+
// COMMON: public var simpleStoredMutable: [[INT]]{{$}}
35+
public var simpleStoredMutable: Int
36+
37+
// CHECK: @_hasStorage public var storedWithObservers: [[BOOL:.*Bool]] {
38+
// RESILIENT: {{^}} public var storedWithObservers: [[BOOL:.*Bool]] {
39+
// COMMON-NEXT: get
40+
// COMMON-NEXT: set
41+
// COMMON-NEXT: }
42+
public var storedWithObservers: Bool {
43+
willSet {}
44+
}
45+
46+
// CHECK: @_hasStorage public var storedPrivateSet: [[INT]] {
47+
// RESILIENT: {{^}} public var storedPrivateSet: [[INT]] {
48+
// COMMON-NEXT: get
49+
// COMMON-NEXT: }
50+
public private(set) var storedPrivateSet: Int
51+
52+
// CHECK: private var _: [[BOOL]]
53+
private var privateVar: Bool
54+
55+
// COMMON: public init(){{$}}
56+
public init() {
57+
self.simpleStoredImmutable = 0
58+
self.simpleStoredMutable = 0
59+
self.storedPrivateSet = 0
60+
self.storedWithObservers = false
61+
self.privateVar = false
62+
}
63+
64+
// COMMON: }
65+
}
66+
67+
// COMMON: @_fixed_layout public struct BagOfVariables {
68+
@_fixed_layout
69+
public struct BagOfVariables {
70+
// COMMON: public let a: [[INT]] = 0
71+
public let a: Int = 0
72+
73+
// COMMON: public var b: [[BOOL]] = false
74+
public var b: Bool = false
75+
76+
// COMMON: public var c: [[INT]] = 0
77+
public var c: Int = 0
78+
79+
// COMMON: public init()
80+
public init() {}
81+
82+
// COMMON: }
83+
}
84+
85+
// COMMON: @_fixed_layout public struct HasStoredPropertiesFixedLayout {
86+
@_fixed_layout
87+
public struct HasStoredPropertiesFixedLayout {
88+
// COMMON: public var simpleStoredMutable: [[BAGOFVARIABLES:.*BagOfVariables]]
89+
public var simpleStoredMutable: BagOfVariables
90+
91+
// COMMON: @_hasStorage public var storedWithObservers: [[BAGOFVARIABLES]] {
92+
// COMMON-NEXT: get
93+
// COMMON-NEXT: set
94+
// COMMON-NEXT: }
95+
public var storedWithObservers: BagOfVariables {
96+
didSet {}
97+
}
98+
99+
// COMMON: public init(){{$}}
100+
public init() {
101+
self.simpleStoredMutable = BagOfVariables()
102+
self.storedWithObservers = BagOfVariables()
103+
}
104+
}

test/SILOptimizer/accessed_storage_analysis.sil

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class C {
340340

341341
// CHECK-LABEL: @readIdentifiedClass
342342
// CHECK: [read] Class %0 = argument of bb0 : $C
343-
// CHECK: Field: @_hasStorage var property: Int
343+
// CHECK: Field: var property: Int
344344
sil @readIdentifiedClass : $@convention(thin) (@guaranteed C) -> Int {
345345
bb0(%0 : $C):
346346
%1 = ref_element_addr %0 : $C, #C.property
@@ -352,7 +352,7 @@ bb0(%0 : $C):
352352

353353
// CHECK-LABEL: @writeIdentifiedClass
354354
// CHECK: [modify] Class %0 = argument of bb0 : $C
355-
// CHECK: Field: @_hasStorage var property: Int
355+
// CHECK: Field: var property: Int
356356
sil @writeIdentifiedClass : $@convention(thin) (@guaranteed C, Int) -> () {
357357
bb0(%0 : $C, %1 : $Int):
358358
%2 = ref_element_addr %0 : $C, #C.property
@@ -365,7 +365,7 @@ bb0(%0 : $C, %1 : $Int):
365365

366366
// CHECK-LABEL: @readWriteIdentifiedClass
367367
// CHECK: [modify] Class %1 = alloc_ref $C
368-
// CHECK: Field: @_hasStorage var property: Int
368+
// CHECK: Field: var property: Int
369369
sil @readWriteIdentifiedClass : $@convention(thin) (Int) -> (Int) {
370370
bb0(%0 : $Int):
371371
%1 = alloc_ref $C
@@ -380,7 +380,7 @@ bb0(%0 : $Int):
380380

381381
// CHECK-LABEL: @readIdentifiedNestedClass
382382
// CHECK: [read] Class %0 = argument of bb0 : $C
383-
// CHECK: Field: @_hasStorage var property: Int
383+
// CHECK: Field: var property: Int
384384
sil @readIdentifiedNestedClass : $@convention(thin) (@guaranteed C) -> Int {
385385
bb0(%0 : $C):
386386
%1 = ref_element_addr %0 : $C, #C.property
@@ -394,7 +394,7 @@ bb0(%0 : $C):
394394

395395
// CHECK-LABEL: @writeIdentifiedNestedClass
396396
// CHECK: [modify] Class %0 = argument of bb0 : $C
397-
// CHECK: Field: @_hasStorage var property: Int
397+
// CHECK: Field: var property: Int
398398
sil @writeIdentifiedNestedClass : $@convention(thin) (@guaranteed C, Int) -> () {
399399
bb0(%0 : $C, %1 : $Int):
400400
%2 = ref_element_addr %0 : $C, #C.property
@@ -409,7 +409,7 @@ bb0(%0 : $C, %1 : $Int):
409409

410410
// CHECK-LABEL: @readWriteIdentifiedNestedClass
411411
// CHECK: [modify] Class %1 = alloc_ref $C
412-
// CHECK: Field: @_hasStorage var property: Int
412+
// CHECK: Field: var property: Int
413413
sil @readWriteIdentifiedNestedClass : $@convention(thin) (Int) -> (Int) {
414414
bb0(%0 : $Int):
415415
%1 = alloc_ref $C
@@ -541,7 +541,7 @@ bb0(%0 : $*Int, %1 : $*Int):
541541
// Test directly recursive argument access.
542542
// CHECK-LABEL: @readRecursiveArgument
543543
// CHECK: [read] Class %0 = argument of bb0 : $C
544-
// CHECK: Field: @_hasStorage var property: Int
544+
// CHECK: Field: var property: Int
545545
sil @readRecursiveArgument : $@convention(thin) (@guaranteed C, Int) -> Int {
546546
bb0(%0 : $C, %1 : $Int):
547547
%propaddr = ref_element_addr %0 : $C, #C.property
@@ -556,7 +556,7 @@ bb0(%0 : $C, %1 : $Int):
556556
// Test a class argument access from an optional caller value.
557557
// CHECK-LABEL: @readOptionalArgumentInCallee
558558
// CHECK: [read] Class %1 = unchecked_enum_data %0 : $Optional<C>, #Optional.some!enumelt.1
559-
// CHECK: Field: @_hasStorage var property: Int
559+
// CHECK: Field: var property: Int
560560
sil @readOptionalArgumentInCallee : $@convention(thin) (@guaranteed Optional<C>) -> Int {
561561
bb0(%0 : $Optional<C>):
562562
%c = unchecked_enum_data %0 : $Optional<C>, #Optional.some!enumelt.1
@@ -567,7 +567,7 @@ bb0(%0 : $Optional<C>):
567567

568568
// CHECK-LABEL: @readOptionalArgumentInCalleeHelper
569569
// CHECK: [read] Class %0 = argument of bb0 : $C
570-
// CHECK: Field: @_hasStorage var property: Int
570+
// CHECK: Field: var property: Int
571571
sil private @readOptionalArgumentInCalleeHelper : $@convention(thin) (@guaranteed C) -> Int {
572572
bb0(%0 : $C):
573573
%propaddr = ref_element_addr %0 : $C, #C.property

0 commit comments

Comments
 (0)