aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-08-11 00:16:14 +0000
committerJohn McCall <rjmccall@apple.com>2010-08-11 00:16:14 +0000
commitd96a8e771ca9f406f0fa1dd4639997335ae444a7 (patch)
tree7fbb0ec0b7727e1b43f49076e6bd647ec8b187c1 /lib/CodeGen/CGException.cpp
parentf598087b4adfea164acdd5b53ea2951bde740a2d (diff)
Fix a bug in @finally emission in both the fragile and non-fragile EH schemes
where we weren't accounting for the possibility that a @finally block might have internal cleanups and therefore might write to the cleanup destination slot. Fixes <rdar://problem/8293901>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGException.cpp')
-rw-r--r--lib/CodeGen/CGException.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 99105e165f..746f68daee 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -1326,6 +1326,12 @@ namespace {
CGF.EHStack.pushCleanup<CallEndCatchForFinally>(NormalAndEHCleanup,
ForEHVar, EndCatchFn);
+ // Save the current cleanup destination in case there are
+ // cleanups in the finally block.
+ llvm::Value *SavedCleanupDest =
+ CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot(),
+ "cleanup.dest.saved");
+
// Emit the finally block.
CGF.EmitStmt(Body);
@@ -1349,6 +1355,10 @@ namespace {
CGF.Builder.CreateUnreachable();
CGF.EmitBlock(ContBB);
+
+ // Restore the cleanup destination.
+ CGF.Builder.CreateStore(SavedCleanupDest,
+ CGF.getNormalCleanupDestSlot());
}
// Leave the end-catch cleanup. As an optimization, pretend that