diff options
author | John McCall <rjmccall@apple.com> | 2010-08-11 00:16:14 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-11 00:16:14 +0000 |
commit | cebe0ca75e246f2d69be5a97d48547359e5eca52 (patch) | |
tree | 10625fc74746bd3a952c8e1fcc43ad2068ff9c83 /clang/lib/CodeGen/CGException.cpp | |
parent | ccab1dddd1531576e111e574ec04bb5043edcc4e (diff) | |
download | bcm5719-llvm-cebe0ca75e246f2d69be5a97d48547359e5eca52.tar.gz bcm5719-llvm-cebe0ca75e246f2d69be5a97d48547359e5eca52.zip |
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>.
llvm-svn: 110760
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 99105e165f3..746f68daee2 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/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 |