Skip to content

Commit 0823d8b

Browse files
committed
Check for nullptr inside NominalTypeDecl::isResilient
rdar://58049956
1 parent 899cc20 commit 0823d8b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,6 +3533,14 @@ bool NominalTypeDecl::isResilient() const {
35333533
return getModuleContext()->isResilient();
35343534
}
35353535

3536+
static bool isOriginallyDefinedIn(const Decl *D, const ModuleDecl* MD) {
3537+
if (!MD)
3538+
return false;
3539+
if (D->getAlternateModuleName().empty())
3540+
return false;
3541+
return D->getAlternateModuleName() == MD->getName().str();
3542+
}
3543+
35363544
bool NominalTypeDecl::isResilient(ModuleDecl *M,
35373545
ResilienceExpansion expansion) const {
35383546
switch (expansion) {
@@ -3542,8 +3550,8 @@ bool NominalTypeDecl::isResilient(ModuleDecl *M,
35423550
// We consider this decl belongs to the module either it's currently
35433551
// defined in this module or it's originally defined in this module, which
35443552
// is specified by @_originallyDefinedIn
3545-
return M != getModuleContext() &&
3546-
M->getName().str() != getAlternateModuleName() && isResilient();
3553+
return M != getModuleContext() && !isOriginallyDefinedIn(this, M) &&
3554+
isResilient();
35473555
}
35483556
llvm_unreachable("bad resilience expansion");
35493557
}

0 commit comments

Comments
 (0)