From d5b354fd5f93a2ce9fce9e55f24d993b1bef5381 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 7 Jun 2023 14:00:07 -0400 Subject: [PATCH] AST: Spot fix for AbstractStorageDecl::isResilient() --- lib/AST/Decl.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 9f8965cf7bbd3..ead50235b979b 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2796,13 +2796,26 @@ bool AbstractStorageDecl::isResilient() const { return getModuleContext()->isResilient(); } +static bool isOriginallyDefinedIn(const Decl *D, const ModuleDecl* MD) { + if (!MD) + return false; + if (D->getAlternateModuleName().empty()) + return false; + return D->getAlternateModuleName() == MD->getName().str(); +} + bool AbstractStorageDecl::isResilient(ModuleDecl *M, ResilienceExpansion expansion) const { switch (expansion) { case ResilienceExpansion::Minimal: return isResilient(); case ResilienceExpansion::Maximal: - return M != getModuleContext() && isResilient(); + // We consider this decl belongs to the module either it's currently + // defined in this module or it's originally defined in this module, which + // is specified by @_originallyDefinedIn + return (M != getModuleContext() && + !isOriginallyDefinedIn(this, M) && + isResilient()); } llvm_unreachable("bad resilience expansion"); } @@ -4736,14 +4749,6 @@ DestructorDecl *NominalTypeDecl::getValueTypeDestructor() { return cast(found[0]); } -static bool isOriginallyDefinedIn(const Decl *D, const ModuleDecl* MD) { - if (!MD) - return false; - if (D->getAlternateModuleName().empty()) - return false; - return D->getAlternateModuleName() == MD->getName().str(); -} - bool NominalTypeDecl::isResilient(ModuleDecl *M, ResilienceExpansion expansion) const { switch (expansion) { @@ -4753,8 +4758,9 @@ bool NominalTypeDecl::isResilient(ModuleDecl *M, // We consider this decl belongs to the module either it's currently // defined in this module or it's originally defined in this module, which // is specified by @_originallyDefinedIn - return M != getModuleContext() && !isOriginallyDefinedIn(this, M) && - isResilient(); + return (M != getModuleContext() && + !isOriginallyDefinedIn(this, M) && + isResilient()); } llvm_unreachable("bad resilience expansion"); }