mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #12280 from adrian-prantl/18296829
Debug Info: Represent private discriminators in DWARF.
This commit is contained in:
@@ -1433,6 +1433,34 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
|
||||
llvm_unreachable("bad access semantics");
|
||||
}
|
||||
|
||||
static bool hasPrivateOrFilePrivateFormalAccess(const ValueDecl *D) {
|
||||
return D->hasAccess() && D->getFormalAccess() <= AccessLevel::FilePrivate;
|
||||
}
|
||||
|
||||
/// Returns true if one of the ancestor DeclContexts of this ValueDecl is either
|
||||
/// marked private or fileprivate or is a local context.
|
||||
static bool isInPrivateOrLocalContext(const ValueDecl *D) {
|
||||
const DeclContext *DC = D->getDeclContext();
|
||||
if (!DC->isTypeContext()) {
|
||||
assert((DC->isModuleScopeContext() || DC->isLocalContext()) &&
|
||||
"unexpected context kind");
|
||||
return DC->isLocalContext();
|
||||
}
|
||||
|
||||
auto *nominal = DC->getAsNominalTypeOrNominalTypeExtensionContext();
|
||||
if (nominal == nullptr)
|
||||
return false;
|
||||
|
||||
if (hasPrivateOrFilePrivateFormalAccess(nominal))
|
||||
return true;
|
||||
return isInPrivateOrLocalContext(nominal);
|
||||
}
|
||||
|
||||
bool ValueDecl::isOutermostPrivateOrFilePrivateScope() const {
|
||||
return hasPrivateOrFilePrivateFormalAccess(this) &&
|
||||
!isInPrivateOrLocalContext(this);
|
||||
}
|
||||
|
||||
bool AbstractStorageDecl::hasFixedLayout() const {
|
||||
// If we're in a nominal type, just query the type.
|
||||
auto *dc = getDeclContext();
|
||||
|
||||
Reference in New Issue
Block a user