AST: @_versioned types and storage are resilient

Use getEffectiveAccess() instead of getFormalAccess() in a few places.

This should be NFC without -enable-resilience.
This commit is contained in:
Slava Pestov
2016-03-17 13:55:06 -07:00
parent ca93fa6d1b
commit 1872a4ee28
6 changed files with 68 additions and 17 deletions

View File

@@ -1213,22 +1213,21 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
}
bool AbstractStorageDecl::hasFixedLayout() const {
// Private and internal variables always have a fixed layout.
// TODO: internal variables with availability information need to be
// resilient, since they can be used from @_transparent functions.
if (getFormalAccess() != Accessibility::Public)
return true;
// Check for an explicit @_fixed_layout attribute.
if (getAttrs().hasAttribute<FixedLayoutAttr>())
return true;
// If we're in a nominal type, just query the type.
auto nominal =
getDeclContext()->getAsNominalTypeOrNominalTypeExtensionContext();
if (nominal)
return nominal->hasFixedLayout();
// Private and (unversioned) internal variables always have a
// fixed layout.
if (getEffectiveAccess() != Accessibility::Public)
return true;
// Check for an explicit @_fixed_layout attribute.
if (getAttrs().hasAttribute<FixedLayoutAttr>())
return true;
// Must use resilient access patterns.
assert(getDeclContext()->isModuleScopeContext());
switch (getDeclContext()->getParentModule()->getResilienceStrategy()) {
@@ -1752,10 +1751,9 @@ Type TypeDecl::getDeclaredInterfaceType() const {
bool NominalTypeDecl::hasFixedLayout() const {
// Private and internal types always have a fixed layout.
// TODO: internal types with availability information need to be
// resilient, since they can be used from @_transparent functions.
if (getFormalAccess() != Accessibility::Public)
// Private and (unversioned) internal types always have a
// fixed layout.
if (getEffectiveAccess() != Accessibility::Public)
return true;
// Check for an explicit @_fixed_layout attribute.