Skip to content

Commit b9cd6ca

Browse files
committed
SILGen: Emit hoisted declarations at the top level
1 parent 5746322 commit b9cd6ca

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,12 @@ class SILGenModuleRAII {
18891889
SGM.visit(D);
18901890
}
18911891

1892+
for (Decl *D : sf->getHoistedDecls()) {
1893+
FrontendStatsTracer StatsTracer(SGM.getASTContext().Stats,
1894+
"SILgen-decl", D);
1895+
SGM.visit(D);
1896+
}
1897+
18921898
for (TypeDecl *TD : sf->LocalTypeDecls) {
18931899
FrontendStatsTracer StatsTracer(SGM.getASTContext().Stats,
18941900
"SILgen-tydecl", TD);

lib/SILGen/SILGenStmt.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,13 @@ void StmtEmitter::visitBraceStmt(BraceStmt *S) {
346346
} else if (auto *E = ESD.dyn_cast<Expr*>()) {
347347
SGF.emitIgnoredExpr(E);
348348
} else {
349-
SGF.visit(ESD.get<Decl*>());
349+
auto *D = ESD.get<Decl*>();
350+
351+
// Hoisted declarations are emitted at the top level by emitSourceFile().
352+
if (D->isHoisted())
353+
continue;
354+
355+
SGF.visit(D);
350356
}
351357
}
352358
}

0 commit comments

Comments
 (0)