summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-02-05 00:58:46 +0000
committerReid Kleckner <reid@kleckner.net>2015-02-05 00:58:46 +0000
commit16f9a6b43dff53f8a0fe87a9ab1309b8474f3dd2 (patch)
tree374e61f6da1ca0f2b71aa7a0e0ab7970124d4664 /clang/lib/CodeGen/CGException.cpp
parent9c26d80c18618dae55a65454b54e05ef33c2d786 (diff)
downloadbcm5719-llvm-16f9a6b43dff53f8a0fe87a9ab1309b8474f3dd2.tar.gz
bcm5719-llvm-16f9a6b43dff53f8a0fe87a9ab1309b8474f3dd2.zip
Fix crash on finally blocks that don't fall through
llvm-svn: 228243
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index e90f56810dd..89c1a2d9588 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1902,12 +1902,20 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S, SEHFinallyInfo &FI) {
// Just pop the cleanup if it's a __finally block.
if (const SEHFinallyStmt *Finally = S.getFinallyHandler()) {
PopCleanupBlock();
+ assert(FI.ContBB && "did not emit normal cleanup");
// Emit the code into FinallyBB.
Builder.SetInsertPoint(FI.FinallyBB);
EmitStmt(Finally->getBlock());
- assert(FI.ContBB);
+ // If the finally block doesn't fall through, we don't need these blocks.
+ if (!HaveInsertPoint()) {
+ FI.ContBB->eraseFromParent();
+ if (FI.ResumeBB)
+ FI.ResumeBB->eraseFromParent();
+ return;
+ }
+
if (FI.ResumeBB) {
llvm::Value *IsEH = Builder.CreateLoad(getAbnormalTerminationSlot(),
"abnormal.termination");
OpenPOWER on IntegriCloud