mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILGen: Don't skip functions nested in closures in inlinable functions.
The logic for walking up the tree of DeclContexts did not handle closures correctly. Resolves rdar://119350220
This commit is contained in:
@@ -804,24 +804,23 @@ bool SILGenModule::shouldSkipDecl(Decl *D) {
|
||||
if (!getASTContext().SILOpts.SkipNonExportableDecls)
|
||||
return false;
|
||||
|
||||
if (auto *afd = dyn_cast<AbstractFunctionDecl>(D)) {
|
||||
do {
|
||||
if (afd->isExposedToClients())
|
||||
return false;
|
||||
if (D->isExposedToClients())
|
||||
return false;
|
||||
|
||||
// If this function is nested within another function that is exposed to
|
||||
// clients then it should be emitted.
|
||||
auto dc = afd->getDeclContext()->getAsDecl();
|
||||
afd = dc ? dyn_cast<AbstractFunctionDecl>(dc) : nullptr;
|
||||
} while (afd);
|
||||
if (isa<AbstractFunctionDecl>(D)) {
|
||||
// If this function is nested within another function that is exposed to
|
||||
// clients then it should be emitted.
|
||||
auto dc = D->getDeclContext();
|
||||
do {
|
||||
if (auto afd = dyn_cast<AbstractFunctionDecl>(dc))
|
||||
if (afd->isExposedToClients())
|
||||
return false;
|
||||
} while ((dc = dc->getParent()));
|
||||
|
||||
// We didn't find a parent function that is exposed.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (D->isExposedToClients())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user