Skip to content

Commit c6874bb

Browse files
authored
Merge pull request #20512 from harlanhaskins/storage-wars
2 parents 1113bde + 66a61c5 commit c6874bb

File tree

73 files changed

+154
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+154
-154
lines changed

include/swift/AST/Attr.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(override, Override,
245245
OnFunc | OnAccessor | OnVar | OnSubscript | OnConstructor | OnAssociatedType |
246246
DeclModifier |
247247
NotSerialized, 44)
248-
SIMPLE_DECL_ATTR(sil_stored, SILStored,
248+
SIMPLE_DECL_ATTR(_hasStorage, HasStorage,
249249
OnVar |
250-
SILOnly |
250+
UserInaccessible |
251251
NotSerialized, 45)
252252
DECL_ATTR(private, AccessControl,
253253
OnFunc | OnAccessor | OnExtension | OnGenericType | OnVar | OnSubscript |

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,12 +2355,12 @@ static void printParameterFlags(ASTPrinter &printer, PrintOptions options,
23552355

23562356
void PrintAST::visitVarDecl(VarDecl *decl) {
23572357
printDocumentationComment(decl);
2358-
// Print @sil_stored when the attribute is not already
2358+
// Print @_hasStorage when the attribute is not already
23592359
// on, decl has storage and it is on a class.
23602360
if (Options.PrintForSIL && decl->hasStorage() &&
23612361
isStructOrClassContext(decl->getDeclContext()) &&
2362-
!decl->getAttrs().hasAttribute<SILStoredAttr>())
2363-
Printer << "@sil_stored ";
2362+
!decl->getAttrs().hasAttribute<HasStorageAttr>())
2363+
Printer << "@_hasStorage ";
23642364
printAttributes(decl);
23652365
printAccess(decl);
23662366
if (!Options.SkipIntroducerKeywords) {

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4672,7 +4672,7 @@ Parser::parseDeclVarGetSet(Pattern *pattern, ParseDeclOptions Flags,
46724672
}
46734673

46744674
// Reject accessors on 'let's after parsing them (for better recovery).
4675-
if (PrimaryVar->isLet() && !Attributes.hasAttribute<SILStoredAttr>()) {
4675+
if (PrimaryVar->isLet() && !Attributes.hasAttribute<HasStorageAttr>()) {
46764676
Diag<> DiagID;
46774677
if (accessors.WillSet || accessors.DidSet)
46784678
DiagID = diag::let_cannot_be_observing_property;
@@ -4935,9 +4935,9 @@ Parser::ParsedAccessors::classify(Parser &P, AbstractStorageDecl *storage,
49354935
readWriteImpl = ReadWriteImplKind::Immutable;
49364936
}
49374937

4938-
// Allow the sil_stored attribute to override all the accessors we parsed
4938+
// Allow the _hasStorage attribute to override all the accessors we parsed
49394939
// when making the final classification.
4940-
if (attrs.hasAttribute<SILStoredAttr>()) {
4940+
if (attrs.hasAttribute<HasStorageAttr>()) {
49414941
return StorageImplInfo::getSimpleStored(StorageIsMutable_t(Set != nullptr));
49424942
}
49434943

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
285285
void visitAccessControlAttr(AccessControlAttr *attr);
286286
void visitSetterAccessAttr(SetterAccessAttr *attr);
287287
bool visitAbstractAccessControlAttr(AbstractAccessControlAttr *attr);
288-
void visitSILStoredAttr(SILStoredAttr *attr);
288+
void visitHasStorageAttr(HasStorageAttr *attr);
289289
void visitObjCMembersAttr(ObjCMembersAttr *attr);
290290
};
291291
} // end anonymous namespace
@@ -428,7 +428,7 @@ void AttributeEarlyChecker::visitGKInspectableAttr(GKInspectableAttr *attr) {
428428
attr->getAttrName());
429429
}
430430

431-
void AttributeEarlyChecker::visitSILStoredAttr(SILStoredAttr *attr) {
431+
void AttributeEarlyChecker::visitHasStorageAttr(HasStorageAttr *attr) {
432432
auto *VD = cast<VarDecl>(D);
433433
if (VD->getDeclContext()->getSelfClassDecl())
434434
return;
@@ -819,6 +819,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
819819
IGNORED_ATTR(Exported)
820820
IGNORED_ATTR(ForbidSerializingReference)
821821
IGNORED_ATTR(GKInspectable)
822+
IGNORED_ATTR(HasStorage)
822823
IGNORED_ATTR(IBDesignable)
823824
IGNORED_ATTR(IBInspectable)
824825
IGNORED_ATTR(IBOutlet) // checked early.
@@ -846,7 +847,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
846847
IGNORED_ATTR(Semantics)
847848
IGNORED_ATTR(ShowInInterface)
848849
IGNORED_ATTR(SILGenName)
849-
IGNORED_ATTR(SILStored)
850850
IGNORED_ATTR(StaticInitializeObjCMetadata)
851851
IGNORED_ATTR(SynthesizedProtocol)
852852
IGNORED_ATTR(Testable)

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ namespace {
12241224
UNINTERESTING_ATTR(SynthesizedProtocol)
12251225
UNINTERESTING_ATTR(RequiresStoredPropertyInits)
12261226
UNINTERESTING_ATTR(Transparent)
1227-
UNINTERESTING_ATTR(SILStored)
1227+
UNINTERESTING_ATTR(HasStorage)
12281228
UNINTERESTING_ATTR(Testable)
12291229

12301230
UNINTERESTING_ATTR(WarnUnqualifiedAccess)

test/IRGen/access_markers.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import Builtin
44
import Swift
55

66
class A {
7-
@sil_stored var property: Int { get set }
8-
@sil_stored var exProperty: Any { get set }
7+
@_hasStorage var property: Int { get set }
8+
@_hasStorage var exProperty: Any { get set }
99
deinit
1010
init()
1111
}

test/IRGen/class_stack_alloc.sil

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ import Builtin
44
import Swift
55

66
class TestClass {
7-
@sil_stored var a : Int64
7+
@_hasStorage var a : Int64
88
init()
99
}
1010

1111
struct TestStruct {
12-
@sil_stored var a : Int64
13-
@sil_stored var b : Int64
14-
@sil_stored var c : Int64
12+
@_hasStorage var a : Int64
13+
@_hasStorage var b : Int64
14+
@_hasStorage var c : Int64
1515
}
1616

1717
class BigClass {
18-
@sil_stored var a : Int64
19-
@sil_stored var b : Int64
20-
@sil_stored var c : Int64
21-
@sil_stored var d : Int64
22-
@sil_stored var e : Int64
23-
@sil_stored var f : Int64
24-
@sil_stored var g : Int64
18+
@_hasStorage var a : Int64
19+
@_hasStorage var b : Int64
20+
@_hasStorage var c : Int64
21+
@_hasStorage var d : Int64
22+
@_hasStorage var e : Int64
23+
@_hasStorage var f : Int64
24+
@_hasStorage var g : Int64
2525
init()
2626
}
2727

test/IRGen/constant_struct_with_padding.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import Builtin
66
import Swift
77

88
struct T {
9-
@sil_stored var a: Builtin.Int1 { get set }
10-
@sil_stored var b: Builtin.Int32 { get set }
9+
@_hasStorage var a: Builtin.Int1 { get set }
10+
@_hasStorage var b: Builtin.Int32 { get set }
1111
}
1212

1313
// CHECK: @global = hidden global %T4main1TV <{ i1 false, [3 x i8] undef, i32 0 }>, align 4

test/IRGen/exactcast.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Swift
99
import SwiftShims
1010

1111
class Node {
12-
@sil_stored var index: Int { get set }
12+
@_hasStorage var index: Int { get set }
1313
init(index: Int)
1414
func check() -> Int
1515
@objc deinit

test/IRGen/exclusivity.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sil_stage canonical
55
import Swift
66

77
class A {
8-
@sil_stored final var x: Int { get set }
8+
@_hasStorage final var x: Int { get set }
99
init(x: Int)
1010
}
1111
sil_vtable A {}

test/IRGen/existentials_objc.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ protocol TestP : AnyObject {}
186186
class NSObject {}
187187

188188
class TestC {
189-
@sil_stored unowned final let t: @sil_unowned NSObject & TestP
189+
@_hasStorage unowned final let t: @sil_unowned NSObject & TestP
190190
init(t: NSObject & TestP)
191191
}
192192

test/IRGen/keypaths_objc.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
class C: NSObject {
1111
@objc dynamic var x: NSString { get }
12-
@sil_stored final var stored: Int
12+
@_hasStorage final var stored: Int
1313
override init()
1414
}
1515

test/IRGen/property_descriptor.sil

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ sil_stage canonical
77
import Swift
88

99
public struct ExternalGeneric<T: Comparable> {
10-
@sil_stored public var ro: T { get }
11-
@sil_stored public var rw: T { get set }
10+
@_hasStorage public var ro: T { get }
11+
@_hasStorage public var rw: T { get set }
1212

1313
public var computedRO: T { get }
1414
public var computedRW: T { get set }
@@ -21,8 +21,8 @@ public struct ExternalGeneric<T: Comparable> {
2121
}
2222

2323
public struct External {
24-
@sil_stored public var ro: Int { get }
25-
@sil_stored public var rw: Int { get set }
24+
@_hasStorage public var ro: Int { get }
25+
@_hasStorage public var rw: Int { get set }
2626

2727
public var computedRO: Int { get }
2828
public var computedRW: Int { get set }
@@ -35,8 +35,8 @@ public struct External {
3535
}
3636

3737
public struct ExternalReabstractions<T> {
38-
@sil_stored public var ro: T { get }
39-
@sil_stored public var reabstracted: () -> () { get set }
38+
@_hasStorage public var ro: T { get }
39+
@_hasStorage public var reabstracted: () -> () { get set }
4040
}
4141

4242
// -- struct property, offset resolved from field offset vector in metadata

test/IRGen/reference_storage_extra_inhabitants.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class C { }
99
sil_vtable C { }
1010

1111
struct S {
12-
@sil_stored unowned(unsafe) var uu: @sil_unmanaged C? { get set }
12+
@_hasStorage unowned(unsafe) var uu: @sil_unmanaged C? { get set }
1313
}
1414

1515
func example(_ os: S?)

test/IRGen/static_initializer.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sil_global @$s6nested1xAA2S2Vv : $S2 = {
4747
// CHECK: @"$s6nested1xAA2S2Vv" = {{(protected )?}}global %T18static_initializer2S2V <{ %Ts5Int32V <{ i32 2 }>, %Ts5Int32V <{ i32 3 }>, %T18static_initializer1SV <{ %Ts5Int32V <{ i32 4 }> }> }>, align 4
4848

4949
final class TestArrayStorage {
50-
@sil_stored var count: Int32
50+
@_hasStorage var count: Int32
5151
init()
5252
}
5353

@@ -78,8 +78,8 @@ sil_global @static_aligned_array : $TestArrayStorage = {
7878
// CHECK: @static_aligned_array = {{(protected )?}}global %T18static_initializer16TestArrayStorageC_tailelems1c { [2 x i64] zeroinitializer, %T18static_initializer16TestArrayStorageC_tailelems1 <{ %swift.refcounted zeroinitializer, %Ts5Int32V <{ i32 2 }>, [12 x i8] undef, %Ts7Float80V <{ x86_fp80 0xK3FFE8000000000000000 }> }> }, align 16
7979

8080
final class ClassWithEmptyField {
81-
@sil_stored var x: Int32
82-
@sil_stored var y: ()
81+
@_hasStorage var x: Int32
82+
@_hasStorage var y: ()
8383
init()
8484
}
8585

test/IRGen/tail_alloc.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Swift
99

1010
// sizeof(TestClass) = 16 bytes header + 1 byte = 17 bytes
1111
class TestClass {
12-
@sil_stored var a : Int8
12+
@_hasStorage var a : Int8
1313
init()
1414
}
1515

test/SIL/Parser/basic.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Swift
99
sil_global private @globalinit_token0 : $Builtin.Word
1010

1111
class TestArrayStorage {
12-
@sil_stored var count: Int32
12+
@_hasStorage var count: Int32
1313
init()
1414
}
1515

@@ -1622,7 +1622,7 @@ bb0(%0 : $(Builtin.NativeObject, Builtin.Int32), %1 : $TestArray2):
16221622
}
16231623

16241624
class A {
1625-
@sil_stored var property: Any { get set }
1625+
@_hasStorage var property: Any { get set }
16261626
deinit
16271627
init()
16281628
}

test/SIL/Parser/final.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s
22

33
// CHECK: final class Rect
4-
// CHECK: @sil_stored @_hasInitialValue final var orgx: Double
4+
// CHECK: @_hasStorage @_hasInitialValue final var orgx: Double
55
final class Rect {
66
var orgx = 0.0
77
}
88

99
protocol P { }
1010
// CHECK: struct Rect2 : P {
11-
// CHECK: @sil_stored @_hasInitialValue var orgx: Double
11+
// CHECK: @_hasStorage @_hasInitialValue var orgx: Double
1212
struct Rect2 : P {
1313
var orgx = 0.0
1414
}

test/SIL/Parser/stored_property.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import Swift
44

5-
// CHECK: @sil_stored var orgx
5+
// CHECK: @_hasStorage var orgx
66
class Rect {
7-
@sil_stored var orgx: Double { get }
7+
@_hasStorage var orgx: Double { get }
88
init(orgx: Double)
99
}
1010

test/SIL/Serialization/basic.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bb0(%0 : @owned $Builtin.NativeObject):
2323
}
2424

2525
class TestArrayStorage {
26-
@sil_stored var count: Int32
26+
@_hasStorage var count: Int32
2727
init()
2828
}
2929

test/SIL/ownership-verifier/definite_init.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ bb0(%0 : @owned $DerivedClassWithIVars, %i : @trivial $Builtin.Int32):
529529

530530

531531
struct MyStruct3 {
532-
@sil_stored var c: C
532+
@_hasStorage var c: C
533533
}
534534
sil @selfinit_mystruct3 : $@convention(thin) () -> @owned MyStruct3
535535

test/SILGen/synthesized_conformance_class.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final class Final<T> {
55
init(x: T) { self.x = x }
66
}
77
// CHECK-LABEL: final class Final<T> {
8-
// CHECK: @sil_stored final var x: T { get set }
8+
// CHECK: @_hasStorage final var x: T { get set }
99
// CHECK: init(x: T)
1010
// CHECK: deinit
1111
// CHECK: enum CodingKeys : CodingKey {
@@ -25,7 +25,7 @@ class Nonfinal<T> {
2525
init(x: T) { self.x = x }
2626
}
2727
// CHECK-LABEL: class Nonfinal<T> {
28-
// CHECK: @sil_stored var x: T { get set }
28+
// CHECK: @_hasStorage var x: T { get set }
2929
// CHECK: init(x: T)
3030
// CHECK: deinit
3131
// CHECK: enum CodingKeys : CodingKey {

test/SILGen/synthesized_conformance_struct.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct Struct<T> {
66
}
77

88
// CHECK-LABEL: struct Struct<T> {
9-
// CHECK: @sil_stored var x: T { get set }
9+
// CHECK: @_hasStorage var x: T { get set }
1010
// CHECK: init(x: T)
1111
// CHECK: enum CodingKeys : CodingKey {
1212
// CHECK: case x

test/SILOptimizer/abcopts.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct ArrayIntBuffer {
1313
}
1414

1515
final class StorageBase {
16-
@sil_stored var header: Int64
16+
@_hasStorage var header: Int64
1717
}
1818

1919
struct ArrayInt{

test/SILOptimizer/access_dom.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Swift
1111
import SwiftShims
1212

1313
struct X {
14-
@sil_stored var i: Int64 { get set }
14+
@_hasStorage var i: Int64 { get set }
1515
init(i: Int64)
1616
init()
1717
}

test/SILOptimizer/access_enforcement_opts.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import c_layout
99

1010

1111
struct X {
12-
@sil_stored var i: Int64 { get set }
12+
@_hasStorage var i: Int64 { get set }
1313
init(i: Int64)
1414
init()
1515
}

test/SILOptimizer/access_marker_elim.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Swift
88
import SwiftShims
99

1010
public struct S {
11-
@sil_stored var i: Builtin.Int64 { get set }
11+
@_hasStorage var i: Builtin.Int64 { get set }
1212
init(i: Int)
1313
}
1414

test/SILOptimizer/access_sink.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Swift
1111
import SwiftShims
1212

1313
struct X {
14-
@sil_stored var i: Int64 { get set }
14+
@_hasStorage var i: Int64 { get set }
1515
init(i: Int64)
1616
init()
1717
}

0 commit comments

Comments
 (0)