[llvm-commits] [dragonegg] r164930 - in /dragonegg/trunk: src/Convert.cpp test/validator/c++/EmptyBlock.cpp
Duncan Sands
baldrick at free.fr
Mon Oct 1 02:00:11 PDT 2012
Author: baldrick
Date: Mon Oct 1 04:00:11 2012
New Revision: 164930
URL: http://llvm.org/viewvc/llvm-project?rev=164930&view=rev
Log:
When erasing a pointless block move the IRBuilder off it, otherwise the deleted
memory may be accessed later.
Added:
dragonegg/trunk/test/validator/c++/EmptyBlock.cpp
Modified:
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=164930&r1=164929&r2=164930&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Mon Oct 1 04:00:11 2012
@@ -1402,14 +1402,16 @@
} else { // !ReturnBB
BasicBlock *CurBB = Builder.GetInsertBlock();
if (CurBB->getTerminator() == 0) {
- if (CurBB->getName().empty() && CurBB->begin() == CurBB->end())
+ if (CurBB->getName().empty() && CurBB->begin() == CurBB->end()) {
// If the previous block has no label and is empty, remove it: it is a
// post-terminator block.
CurBB->eraseFromParent();
- else
+ Builder.SetInsertPoint(&Fn->getBasicBlockList().back());
+ } else {
// The previous block may contain code but no terminator if it finished
// with an unsupported GCC builtin.
Builder.CreateUnreachable();
+ }
}
}
Added: dragonegg/trunk/test/validator/c++/EmptyBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c%2B%2B/EmptyBlock.cpp?rev=164930&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c++/EmptyBlock.cpp (added)
+++ dragonegg/trunk/test/validator/c++/EmptyBlock.cpp Mon Oct 1 04:00:11 2012
@@ -0,0 +1,14 @@
+// RUN: %dragonegg -S %s -O1
+// GCC PR c++/11878
+
+struct A
+{
+ virtual ~A();
+};
+
+template<typename T> struct B
+{
+ T t;
+};
+
+void foo() { throw B<A>().t; }
More information about the llvm-commits
mailing list