diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-05-23 20:00:44 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-05-23 20:00:44 +0000 |
commit | 92b9bd96ce25630f73717965fcaf4b5a761e49e5 (patch) | |
tree | 03e854ab61ce4e1a671e95c14e1b12d1451ee94c | |
parent | a481ec4150ad203440852a2bfee0883dd26f7530 (diff) |
PR5863: Don't erase unreachable BBs which have an associated cleanup size.
This works around a crash where malloc reused the memory of an erased BB for a
new BB leaving old cleanup information pointing at the new block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104472 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenCXX/PR5863-unreachable-block.cpp | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 589273da43..3e807bdbc7 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -80,7 +80,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { // explicitly here. This handles the common case of a call to a noreturn // function. if (llvm::BasicBlock *CurBB = Builder.GetInsertBlock()) { - if (CurBB->empty() && CurBB->use_empty()) { + if (CurBB->empty() && CurBB->use_empty() && !BlockScopes.count(CurBB)) { CurBB->eraseFromParent(); Builder.ClearInsertionPoint(); } diff --git a/test/CodeGenCXX/PR5863-unreachable-block.cpp b/test/CodeGenCXX/PR5863-unreachable-block.cpp new file mode 100644 index 0000000000..91221c9a7a --- /dev/null +++ b/test/CodeGenCXX/PR5863-unreachable-block.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm-only %s + +// PR5836 +class E { }; + +void P1() { + try { + int a=0, b=0; + if (a > b) // simply filling in 0 or 1 doesn't trigger the assertion + throw E(); // commenting out 'if' or 'throw' 'fixes' the assertion failure + try { } catch (...) { } // empty try/catch block needed for failure + } catch (...) { } // this try/catch block needed for failure +} |