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
This commit is contained in:
John McCall
2010-08-11 00:16:14 +00:00
parent ccab1dddd1
commit cebe0ca75e
3 changed files with 77 additions and 5 deletions

View File

@@ -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