summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-01-12 03:41:02 +0000
committerJohn McCall <rjmccall@apple.com>2011-01-12 03:41:02 +0000
commit20f6ab828a18d21091060966b42bbb4b2908a312 (patch)
treebfafeec67298e4f260e34cdd81b78695cebea06a /clang/lib/CodeGen/CGException.cpp
parentdd5f60b7a7c99f33d63fc2ce660850ba1c0f22b8 (diff)
downloadbcm5719-llvm-20f6ab828a18d21091060966b42bbb4b2908a312.tar.gz
bcm5719-llvm-20f6ab828a18d21091060966b42bbb4b2908a312.zip
Fix a latent bug where, after emitting an expression statement, we would
delete the block we began emitting into if it had no predecessors. We never want to do this, because there are several valid cases during statement emission where an existing block has no known predecessors but will acquire some later. The case in my test case doesn't inherently fall into this category, because we could safely emit the case-range code before the statement body, but there are examples with labels that can't be fallen into that would also demonstrate this bug. rdar://problem/8837067 llvm-svn: 123303
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 11e5e645280..252e547b5d1 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -577,8 +577,10 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
Builder.CreateUnreachable();
}
- // Clear the insertion point to indicate we are in unreachable code.
- Builder.ClearInsertionPoint();
+ // throw is an expression, and the expression emitters expect us
+ // to leave ourselves at a valid insertion point.
+ EmitBlock(createBasicBlock("throw.cont"));
+
return;
}
@@ -627,12 +629,9 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
Builder.CreateUnreachable();
}
- // Clear the insertion point to indicate we are in unreachable code.
- Builder.ClearInsertionPoint();
-
- // FIXME: For now, emit a dummy basic block because expr emitters in generally
- // are not ready to handle emitting expressions at unreachable points.
- EnsureInsertPoint();
+ // throw is an expression, and the expression emitters expect us
+ // to leave ourselves at a valid insertion point.
+ EmitBlock(createBasicBlock("throw.cont"));
}
void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
OpenPOWER on IntegriCloud