[ParseableInterface] Go through pattern binding for all variables with storage

Instead of only printing through the pattern binding, and potentially missing stored properties with property observers, defer to the pattern binding for all stored properties, and print accessors if applicable while printing pattern bindings.
This commit is contained in:
Harlan Haskins
2018-12-12 16:52:41 -08:00
parent 579f0188e0
commit 7fe74b2b26
3 changed files with 12 additions and 3 deletions

View File

@@ -3230,7 +3230,7 @@ bool Decl::shouldPrintInContext(const PrintOptions &PO) const {
// Stored variables in Swift source will be picked up by the
// PatternBindingDecl.
if (auto *VD = dyn_cast<VarDecl>(this)) {
if (!VD->hasClangNode() && VD->getImplInfo().isSimpleStored())
if (!VD->hasClangNode() && VD->hasStorage())
return false;
}
@@ -3241,7 +3241,7 @@ bool Decl::shouldPrintInContext(const PrintOptions &PO) const {
auto pattern =
pbd->getPatternList()[0].getPattern()->getSemanticsProvidingPattern();
if (auto named = dyn_cast<NamedPattern>(pattern)) {
if (!named->getDecl()->getImplInfo().isSimpleStored())
if (!named->getDecl()->hasStorage())
return false;
}
}

View File

@@ -17,7 +17,7 @@ import StoredProperties
// COMMON: %[[BAGOFVARIABLES:T16StoredProperties14BagOfVariablesV]] = type <{ %TSi, %TSb, [{{(3|7)}} x i8], %TSi }>
// This type is non-@_fixed_layout, so it becomes opaque in a resilient module
// CHECK: %[[HASSTOREDPROPERTIES:T16StoredProperties03HasaB0V]] = type <{ %TSi, %TSi, %TSb, [{{(3|7)}} x i8], %TSi, %TSb }>
// CHECK: %[[HASSTOREDPROPERTIES:T16StoredProperties03HasaB0V]] = type <{ %TSi, %TSi, %TSb, [{{(3|7)}} x i8], %TSi, %TSb, [{{3|7}} x i8], %TSi }>
// RESILIENT: %[[HASSTOREDPROPERTIES:swift.opaque]] = type opaque
// COMMON: %[[HASSTOREDPROPERTIESFIXEDLAYOUT:T16StoredProperties03HasaB11FixedLayoutV]] = type <{ %[[BAGOFVARIABLES]], %[[BAGOFVARIABLES]] }>

View File

@@ -52,6 +52,15 @@ public struct HasStoredProperties {
// CHECK: private var _: [[BOOL]]
private var privateVar: Bool
// CHECK: @_hasStorage @_hasInitialValue public var storedWithObserversInitialValue: [[INT]] {
// RESILIENT: {{^}} @_hasInitialValue public var storedWithObserversInitialValue: [[INT]] {
// COMMON-NEXT: get
// COMMON-NEXT: set
// COMMON-NEXT: }
public var storedWithObserversInitialValue: Int = 0 {
didSet {}
}
// COMMON: public init(){{$}}
public init() {
self.simpleStoredImmutable = 0