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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user