aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-07-21 01:41:18 +0000
committerJohn McCall <rjmccall@apple.com>2010-07-21 01:41:18 +0000
commit291ae949612e371c41bf771a483b407d49372a4f (patch)
tree866f94aa8da0f57fbd5ad251a5978852117011eb /lib/CodeGen/CGClass.cpp
parent182ab5112650d3228291c4dadd64a9f77f5aeb51 (diff)
Change PushDestructorCleanup to use lazy cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108979 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGClass.cpp')
-rw-r--r--lib/CodeGen/CGClass.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp
index bc42ecb3f5..861e66891a 100644
--- a/lib/CodeGen/CGClass.cpp
+++ b/lib/CodeGen/CGClass.cpp
@@ -1144,6 +1144,21 @@ void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *DD,
EmitCXXMemberCall(DD, Callee, ReturnValueSlot(), This, VTT, 0, 0);
}
+namespace {
+ struct CallLocalDtor : EHScopeStack::LazyCleanup {
+ const CXXDestructorDecl *Dtor;
+ llvm::Value *Addr;
+
+ CallLocalDtor(const CXXDestructorDecl *D, llvm::Value *Addr)
+ : Dtor(D), Addr(Addr) {}
+
+ void Emit(CodeGenFunction &CGF, bool IsForEH) {
+ CGF.EmitCXXDestructorCall(Dtor, Dtor_Complete,
+ /*ForVirtualBase=*/false, Addr);
+ }
+ };
+}
+
void CodeGenFunction::PushDestructorCleanup(QualType T, llvm::Value *Addr) {
CXXRecordDecl *ClassDecl = T->getAsCXXRecordDecl();
if (!ClassDecl) return;
@@ -1151,14 +1166,7 @@ void CodeGenFunction::PushDestructorCleanup(QualType T, llvm::Value *Addr) {
const CXXDestructorDecl *D = ClassDecl->getDestructor();
- CleanupBlock Scope(*this, NormalCleanup);
-
- EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false, Addr);
-
- if (Exceptions) {
- Scope.beginEHCleanup();
- EmitCXXDestructorCall(D, Dtor_Complete, /*ForVirtualBase=*/false, Addr);
- }
+ EHStack.pushLazyCleanup<CallLocalDtor>(NormalAndEHCleanup, D, Addr);
}
llvm::Value *