aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-02-08 00:16:35 +0000
committerAnders Carlsson <andersca@mac.com>2009-02-08 00:16:35 +0000
commitbd6fa3d032acd7eafc6c10827c41103df45beab7 (patch)
treed9e1a6f42ccc3322bc0133cef91eebcff2aac3df /lib/CodeGen/CodeGenFunction.cpp
parent69c68b7454dc7f47def4ebf593a584d0f02c1ddb (diff)
When emitting blocks, keep track of which cleanup scope they have. Minor fixes and cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64053 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 838de70218..0e0140c9ad 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -119,7 +119,11 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
assert(BreakContinueStack.empty() &&
"mismatched push/pop in break/continue stack!");
-
+ assert(BlockScopes.empty() &&
+ "did not remove all blocks from block scope map!");
+ assert(CleanupEntries.empty() &&
+ "mismatched push/pop in cleanup stack!");
+
// Emit function epilog (to return).
EmitReturnBlock();
@@ -537,8 +541,22 @@ void CodeGenFunction::EmitCleanupBlock()
llvm::BasicBlock *CleanupBlock = CE.CleanupBlock;
+ std::vector<llvm::BasicBlock *> Blocks;
+ std::swap(Blocks, CE.Blocks);
+
+ std::vector<llvm::BranchInst *> BranchFixups;
+ std::swap(BranchFixups, CE.BranchFixups);
+
CleanupEntries.pop_back();
EmitBlock(CleanupBlock);
+
+ // Remove all blocks from the block scope map.
+ for (size_t i = 0, e = Blocks.size(); i != e; ++i) {
+ assert(BlockScopes.count(Blocks[i]) &&
+ "Did not find block in scope map!");
+
+ BlockScopes.erase(Blocks[i]);
+ }
}