Skip to content

[NFC] Rename @sil_stored to @_hasStorage #20512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(override, Override,
OnFunc | OnAccessor | OnVar | OnSubscript | OnConstructor | OnAssociatedType |
DeclModifier |
NotSerialized, 44)
SIMPLE_DECL_ATTR(sil_stored, SILStored,
SIMPLE_DECL_ATTR(_hasStorage, HasStorage,
OnVar |
SILOnly |
UserInaccessible |
NotSerialized, 45)
DECL_ATTR(private, AccessControl,
OnFunc | OnAccessor | OnExtension | OnGenericType | OnVar | OnSubscript |
Expand Down
6 changes: 3 additions & 3 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,12 +2355,12 @@ static void printParameterFlags(ASTPrinter &printer, PrintOptions options,

void PrintAST::visitVarDecl(VarDecl *decl) {
printDocumentationComment(decl);
// Print @sil_stored when the attribute is not already
// Print @_hasStorage when the attribute is not already
// on, decl has storage and it is on a class.
if (Options.PrintForSIL && decl->hasStorage() &&
isStructOrClassContext(decl->getDeclContext()) &&
!decl->getAttrs().hasAttribute<SILStoredAttr>())
Printer << "@sil_stored ";
!decl->getAttrs().hasAttribute<HasStorageAttr>())
Printer << "@_hasStorage ";
printAttributes(decl);
printAccess(decl);
if (!Options.SkipIntroducerKeywords) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4672,7 +4672,7 @@ Parser::parseDeclVarGetSet(Pattern *pattern, ParseDeclOptions Flags,
}

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

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

Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
void visitAccessControlAttr(AccessControlAttr *attr);
void visitSetterAccessAttr(SetterAccessAttr *attr);
bool visitAbstractAccessControlAttr(AbstractAccessControlAttr *attr);
void visitSILStoredAttr(SILStoredAttr *attr);
void visitHasStorageAttr(HasStorageAttr *attr);
void visitObjCMembersAttr(ObjCMembersAttr *attr);
};
} // end anonymous namespace
Expand Down Expand Up @@ -428,7 +428,7 @@ void AttributeEarlyChecker::visitGKInspectableAttr(GKInspectableAttr *attr) {
attr->getAttrName());
}

void AttributeEarlyChecker::visitSILStoredAttr(SILStoredAttr *attr) {
void AttributeEarlyChecker::visitHasStorageAttr(HasStorageAttr *attr) {
auto *VD = cast<VarDecl>(D);
if (VD->getDeclContext()->getSelfClassDecl())
return;
Expand Down Expand Up @@ -819,6 +819,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
IGNORED_ATTR(Exported)
IGNORED_ATTR(ForbidSerializingReference)
IGNORED_ATTR(GKInspectable)
IGNORED_ATTR(HasStorage)
IGNORED_ATTR(IBDesignable)
IGNORED_ATTR(IBInspectable)
IGNORED_ATTR(IBOutlet) // checked early.
Expand Down Expand Up @@ -846,7 +847,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
IGNORED_ATTR(Semantics)
IGNORED_ATTR(ShowInInterface)
IGNORED_ATTR(SILGenName)
IGNORED_ATTR(SILStored)
IGNORED_ATTR(StaticInitializeObjCMetadata)
IGNORED_ATTR(SynthesizedProtocol)
IGNORED_ATTR(Testable)
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckDeclOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ namespace {
UNINTERESTING_ATTR(SynthesizedProtocol)
UNINTERESTING_ATTR(RequiresStoredPropertyInits)
UNINTERESTING_ATTR(Transparent)
UNINTERESTING_ATTR(SILStored)
UNINTERESTING_ATTR(HasStorage)
UNINTERESTING_ATTR(Testable)

UNINTERESTING_ATTR(WarnUnqualifiedAccess)
Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/access_markers.sil
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Builtin
import Swift

class A {
@sil_stored var property: Int { get set }
@sil_stored var exProperty: Any { get set }
@_hasStorage var property: Int { get set }
@_hasStorage var exProperty: Any { get set }
deinit
init()
}
Expand Down
22 changes: 11 additions & 11 deletions test/IRGen/class_stack_alloc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import Builtin
import Swift

class TestClass {
@sil_stored var a : Int64
@_hasStorage var a : Int64
init()
}

struct TestStruct {
@sil_stored var a : Int64
@sil_stored var b : Int64
@sil_stored var c : Int64
@_hasStorage var a : Int64
@_hasStorage var b : Int64
@_hasStorage var c : Int64
}

class BigClass {
@sil_stored var a : Int64
@sil_stored var b : Int64
@sil_stored var c : Int64
@sil_stored var d : Int64
@sil_stored var e : Int64
@sil_stored var f : Int64
@sil_stored var g : Int64
@_hasStorage var a : Int64
@_hasStorage var b : Int64
@_hasStorage var c : Int64
@_hasStorage var d : Int64
@_hasStorage var e : Int64
@_hasStorage var f : Int64
@_hasStorage var g : Int64
init()
}

Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/constant_struct_with_padding.sil
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Builtin
import Swift

struct T {
@sil_stored var a: Builtin.Int1 { get set }
@sil_stored var b: Builtin.Int32 { get set }
@_hasStorage var a: Builtin.Int1 { get set }
@_hasStorage var b: Builtin.Int32 { get set }
}

// CHECK: @global = hidden global %T4main1TV <{ i1 false, [3 x i8] undef, i32 0 }>, align 4
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/exactcast.sil
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Swift
import SwiftShims

class Node {
@sil_stored var index: Int { get set }
@_hasStorage var index: Int { get set }
init(index: Int)
func check() -> Int
@objc deinit
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/exclusivity.sil
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sil_stage canonical
import Swift

class A {
@sil_stored final var x: Int { get set }
@_hasStorage final var x: Int { get set }
init(x: Int)
}
sil_vtable A {}
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/existentials_objc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protocol TestP : AnyObject {}
class NSObject {}

class TestC {
@sil_stored unowned final let t: @sil_unowned NSObject & TestP
@_hasStorage unowned final let t: @sil_unowned NSObject & TestP
init(t: NSObject & TestP)
}

Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/keypaths_objc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

class C: NSObject {
@objc dynamic var x: NSString { get }
@sil_stored final var stored: Int
@_hasStorage final var stored: Int
override init()
}

Expand Down
12 changes: 6 additions & 6 deletions test/IRGen/property_descriptor.sil
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ sil_stage canonical
import Swift

public struct ExternalGeneric<T: Comparable> {
@sil_stored public var ro: T { get }
@sil_stored public var rw: T { get set }
@_hasStorage public var ro: T { get }
@_hasStorage public var rw: T { get set }

public var computedRO: T { get }
public var computedRW: T { get set }
Expand All @@ -21,8 +21,8 @@ public struct ExternalGeneric<T: Comparable> {
}

public struct External {
@sil_stored public var ro: Int { get }
@sil_stored public var rw: Int { get set }
@_hasStorage public var ro: Int { get }
@_hasStorage public var rw: Int { get set }

public var computedRO: Int { get }
public var computedRW: Int { get set }
Expand All @@ -35,8 +35,8 @@ public struct External {
}

public struct ExternalReabstractions<T> {
@sil_stored public var ro: T { get }
@sil_stored public var reabstracted: () -> () { get set }
@_hasStorage public var ro: T { get }
@_hasStorage public var reabstracted: () -> () { get set }
}

// -- struct property, offset resolved from field offset vector in metadata
Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/reference_storage_extra_inhabitants.sil
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class C { }
sil_vtable C { }

struct S {
@sil_stored unowned(unsafe) var uu: @sil_unmanaged C? { get set }
@_hasStorage unowned(unsafe) var uu: @sil_unmanaged C? { get set }
}

func example(_ os: S?)
Expand Down
6 changes: 3 additions & 3 deletions test/IRGen/static_initializer.sil
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ sil_global @$s6nested1xAA2S2Vv : $S2 = {
// CHECK: @"$s6nested1xAA2S2Vv" = {{(protected )?}}global %T18static_initializer2S2V <{ %Ts5Int32V <{ i32 2 }>, %Ts5Int32V <{ i32 3 }>, %T18static_initializer1SV <{ %Ts5Int32V <{ i32 4 }> }> }>, align 4

final class TestArrayStorage {
@sil_stored var count: Int32
@_hasStorage var count: Int32
init()
}

Expand Down Expand Up @@ -78,8 +78,8 @@ sil_global @static_aligned_array : $TestArrayStorage = {
// 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

final class ClassWithEmptyField {
@sil_stored var x: Int32
@sil_stored var y: ()
@_hasStorage var x: Int32
@_hasStorage var y: ()
init()
}

Expand Down
2 changes: 1 addition & 1 deletion test/IRGen/tail_alloc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Swift

// sizeof(TestClass) = 16 bytes header + 1 byte = 17 bytes
class TestClass {
@sil_stored var a : Int8
@_hasStorage var a : Int8
init()
}

Expand Down
4 changes: 2 additions & 2 deletions test/SIL/Parser/basic.sil
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Swift
sil_global private @globalinit_token0 : $Builtin.Word

class TestArrayStorage {
@sil_stored var count: Int32
@_hasStorage var count: Int32
init()
}

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

class A {
@sil_stored var property: Any { get set }
@_hasStorage var property: Any { get set }
deinit
init()
}
Expand Down
4 changes: 2 additions & 2 deletions test/SIL/Parser/final.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// RUN: %target-swift-frontend %s -emit-silgen | %FileCheck %s

// CHECK: final class Rect
// CHECK: @sil_stored @_hasInitialValue final var orgx: Double
// CHECK: @_hasStorage @_hasInitialValue final var orgx: Double
final class Rect {
var orgx = 0.0
}

protocol P { }
// CHECK: struct Rect2 : P {
// CHECK: @sil_stored @_hasInitialValue var orgx: Double
// CHECK: @_hasStorage @_hasInitialValue var orgx: Double
struct Rect2 : P {
var orgx = 0.0
}
4 changes: 2 additions & 2 deletions test/SIL/Parser/stored_property.sil
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import Swift

// CHECK: @sil_stored var orgx
// CHECK: @_hasStorage var orgx
class Rect {
@sil_stored var orgx: Double { get }
@_hasStorage var orgx: Double { get }
init(orgx: Double)
}

Expand Down
2 changes: 1 addition & 1 deletion test/SIL/Serialization/basic.sil
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bb0(%0 : @owned $Builtin.NativeObject):
}

class TestArrayStorage {
@sil_stored var count: Int32
@_hasStorage var count: Int32
init()
}

Expand Down
2 changes: 1 addition & 1 deletion test/SIL/ownership-verifier/definite_init.sil
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ bb0(%0 : @owned $DerivedClassWithIVars, %i : @trivial $Builtin.Int32):


struct MyStruct3 {
@sil_stored var c: C
@_hasStorage var c: C
}
sil @selfinit_mystruct3 : $@convention(thin) () -> @owned MyStruct3

Expand Down
4 changes: 2 additions & 2 deletions test/SILGen/synthesized_conformance_class.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ final class Final<T> {
init(x: T) { self.x = x }
}
// CHECK-LABEL: final class Final<T> {
// CHECK: @sil_stored final var x: T { get set }
// CHECK: @_hasStorage final var x: T { get set }
// CHECK: init(x: T)
// CHECK: deinit
// CHECK: enum CodingKeys : CodingKey {
Expand All @@ -25,7 +25,7 @@ class Nonfinal<T> {
init(x: T) { self.x = x }
}
// CHECK-LABEL: class Nonfinal<T> {
// CHECK: @sil_stored var x: T { get set }
// CHECK: @_hasStorage var x: T { get set }
// CHECK: init(x: T)
// CHECK: deinit
// CHECK: enum CodingKeys : CodingKey {
Expand Down
2 changes: 1 addition & 1 deletion test/SILGen/synthesized_conformance_struct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct Struct<T> {
}

// CHECK-LABEL: struct Struct<T> {
// CHECK: @sil_stored var x: T { get set }
// CHECK: @_hasStorage var x: T { get set }
// CHECK: init(x: T)
// CHECK: enum CodingKeys : CodingKey {
// CHECK: case x
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/abcopts.sil
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct ArrayIntBuffer {
}

final class StorageBase {
@sil_stored var header: Int64
@_hasStorage var header: Int64
}

struct ArrayInt{
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/access_dom.sil
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Swift
import SwiftShims

struct X {
@sil_stored var i: Int64 { get set }
@_hasStorage var i: Int64 { get set }
init(i: Int64)
init()
}
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/access_enforcement_opts.sil
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import c_layout


struct X {
@sil_stored var i: Int64 { get set }
@_hasStorage var i: Int64 { get set }
init(i: Int64)
init()
}
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/access_marker_elim.sil
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Swift
import SwiftShims

public struct S {
@sil_stored var i: Builtin.Int64 { get set }
@_hasStorage var i: Builtin.Int64 { get set }
init(i: Int)
}

Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/access_sink.sil
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Swift
import SwiftShims

struct X {
@sil_stored var i: Int64 { get set }
@_hasStorage var i: Int64 { get set }
init(i: Int64)
init()
}
Expand Down
Loading