Teach EHCleanupBlock to deal appropriately with the possibility that there
might not have been an insertion block set at start. Fixes PR6975.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102677 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 405df40..a18aaf6 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -696,7 +696,11 @@
// Resume inserting where we started, but put the new cleanup
// handler in place.
- CGF.Builder.SetInsertPoint(PreviousInsertionBlock);
+ if (PreviousInsertionBlock)
+ CGF.Builder.SetInsertPoint(PreviousInsertionBlock);
+ else
+ CGF.Builder.ClearInsertionPoint();
+
if (CGF.Exceptions)
CGF.setInvokeDest(CleanupHandler);
}