mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user