diff options
author | Anders Carlsson <andersca@mac.com> | 2009-02-08 00:16:35 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-02-08 00:16:35 +0000 |
commit | fbfb5e6530f805f7edcb6eca18eb76e47433aac5 (patch) | |
tree | f36a3e62ced1d64efeee64dc2f14002c91d9e2aa /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | cadb9a6a34c0b16619516081eb0691c9cbc74f78 (diff) | |
download | bcm5719-llvm-fbfb5e6530f805f7edcb6eca18eb76e47433aac5.tar.gz bcm5719-llvm-fbfb5e6530f805f7edcb6eca18eb76e47433aac5.zip |
When emitting blocks, keep track of which cleanup scope they have. Minor fixes and cleanup.
llvm-svn: 64053
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 838de70218d..0e0140c9ad7 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/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]); + } } |