Skip to content

Commit d5b354f

Browse files
committed
AST: Spot fix for AbstractStorageDecl::isResilient()
1 parent 7cc8063 commit d5b354f

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

lib/AST/Decl.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,13 +2796,26 @@ bool AbstractStorageDecl::isResilient() const {
27962796
return getModuleContext()->isResilient();
27972797
}
27982798

2799+
static bool isOriginallyDefinedIn(const Decl *D, const ModuleDecl* MD) {
2800+
if (!MD)
2801+
return false;
2802+
if (D->getAlternateModuleName().empty())
2803+
return false;
2804+
return D->getAlternateModuleName() == MD->getName().str();
2805+
}
2806+
27992807
bool AbstractStorageDecl::isResilient(ModuleDecl *M,
28002808
ResilienceExpansion expansion) const {
28012809
switch (expansion) {
28022810
case ResilienceExpansion::Minimal:
28032811
return isResilient();
28042812
case ResilienceExpansion::Maximal:
2805-
return M != getModuleContext() && isResilient();
2813+
// We consider this decl belongs to the module either it's currently
2814+
// defined in this module or it's originally defined in this module, which
2815+
// is specified by @_originallyDefinedIn
2816+
return (M != getModuleContext() &&
2817+
!isOriginallyDefinedIn(this, M) &&
2818+
isResilient());
28062819
}
28072820
llvm_unreachable("bad resilience expansion");
28082821
}
@@ -4736,14 +4749,6 @@ DestructorDecl *NominalTypeDecl::getValueTypeDestructor() {
47364749
return cast<DestructorDecl>(found[0]);
47374750
}
47384751

4739-
static bool isOriginallyDefinedIn(const Decl *D, const ModuleDecl* MD) {
4740-
if (!MD)
4741-
return false;
4742-
if (D->getAlternateModuleName().empty())
4743-
return false;
4744-
return D->getAlternateModuleName() == MD->getName().str();
4745-
}
4746-
47474752
bool NominalTypeDecl::isResilient(ModuleDecl *M,
47484753
ResilienceExpansion expansion) const {
47494754
switch (expansion) {
@@ -4753,8 +4758,9 @@ bool NominalTypeDecl::isResilient(ModuleDecl *M,
47534758
// We consider this decl belongs to the module either it's currently
47544759
// defined in this module or it's originally defined in this module, which
47554760
// is specified by @_originallyDefinedIn
4756-
return M != getModuleContext() && !isOriginallyDefinedIn(this, M) &&
4757-
isResilient();
4761+
return (M != getModuleContext() &&
4762+
!isOriginallyDefinedIn(this, M) &&
4763+
isResilient());
47584764
}
47594765
llvm_unreachable("bad resilience expansion");
47604766
}

0 commit comments

Comments
 (0)