Handle delete where the class has a virtual destructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81733 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 4932692..25e2b13 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -608,11 +608,14 @@
if (!RD->hasTrivialDestructor()) {
const CXXDestructorDecl *Dtor = RD->getDestructor(getContext());
if (Dtor->isVirtual()) {
- ErrorUnsupported(E, "delete expression with virtual destructor");
- return;
- }
-
- EmitCXXDestructorCall(Dtor, Dtor_Complete, Ptr);
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(Dtor),
+ /*isVariadic=*/false);
+
+ llvm::Value *Callee = BuildVirtualCall(Dtor, Ptr, Ty);
+ EmitCXXMemberCall(Dtor, Callee, Ptr, 0, 0);
+ } else
+ EmitCXXDestructorCall(Dtor, Dtor_Complete, Ptr);
}
}
}