aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/StatementGen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/StatementGen.cc')
-rw-r--r--lib/CodeGen/StatementGen.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc
index a7c8eda..df8c396 100644
--- a/lib/CodeGen/StatementGen.cc
+++ b/lib/CodeGen/StatementGen.cc
@@ -31,11 +31,15 @@ void CodeGen::emitStmt(StmtAST *Stmt) {
// to the emitting function), mirroring FunctionGen's Symbols handling.
auto SavedArrays = Arrays->exchangeTable({});
+ auto SavedObjects = std::move(StackObjects);
+ StackObjects.clear();
auto SavedScopes = std::move(ConstantScopes);
ConstantScopes = {{NextScopeID++, {}}};
- FuncGen->emitFunctionDef(FuncDef, [this](StmtAST *S) {
+ Function *Emitted = FuncGen->emitFunctionDef(FuncDef, [this](StmtAST *S) {
this->emitStmt(S);
}, ConstantScopes.back().ID);
+ if (Emitted) finishStackObjects(Emitted);
+ StackObjects = std::move(SavedObjects);
ConstantScopes = std::move(SavedScopes);
Arrays->exchangeTable(std::move(SavedArrays));