[cfe-commits] r88712 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp lib/CodeGen/CGCXXExpr.cpp test/CodeGenCXX/array-operator-delete-call.cpp
Fariborz Jahanian
fjahanian at apple.com
Fri Nov 13 14:29:45 PST 2009
Author: fjahanian
Date: Fri Nov 13 16:29:45 2009
New Revision: 88712
URL: http://llvm.org/viewvc/llvm-project?rev=88712&view=rev
Log:
Code gen. For virtual destructor call on array objects
(still part of pr5472).
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
cfe/trunk/test/CodeGenCXX/array-operator-delete-call.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=88712&r1=88711&r2=88712&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Nov 13 16:29:45 2009
@@ -567,7 +567,16 @@
Counter = Builder.CreateLoad(IndexPtr);
Counter = Builder.CreateSub(Counter, One);
llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
- EmitCXXDestructorCall(D, Dtor_Complete, Address);
+ if (D->isVirtual()) {
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(D),
+ /*isVariadic=*/false);
+
+ llvm::Value *Callee = BuildVirtualCall(D, Dtor_Deleting, Address, Ty);
+ EmitCXXMemberCall(D, Callee, Address, 0, 0);
+ }
+ else
+ EmitCXXDestructorCall(D, Dtor_Complete, Address);
EmitBlock(ContinueBlock);
Modified: cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXExpr.cpp?rev=88712&r1=88711&r2=88712&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXExpr.cpp Fri Nov 13 16:29:45 2009
@@ -293,7 +293,6 @@
Builder.CreateIntCast(NumElements,
llvm::Type::getInt64Ty(VMContext), false,
"count.tmp");
- assert (!Dtor->isVirtual() && "delete [] with virtual dtors NYI");
EmitCXXAggrDestructorCall(Dtor, NumElements, Ptr);
Ptr = AllocatedObjectPtr;
}
Modified: cfe/trunk/test/CodeGenCXX/array-operator-delete-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/array-operator-delete-call.cpp?rev=88712&r1=88711&r2=88712&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/array-operator-delete-call.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/array-operator-delete-call.cpp Fri Nov 13 16:29:45 2009
@@ -13,9 +13,16 @@
int iS;
};
+struct V {
+ V() : iV (++count) { printf("V::V(%d)\n", iV); }
+ virtual ~V() { printf("V::~V(%d)\n", iV); }
+ int iV;
+};
+
struct COST
{
S *cost;
+ V *vcost;
unsigned *cost_val;
~COST();
@@ -26,6 +33,7 @@
COST::COST()
{
cost = new S[3];
+ vcost = new V[4];
cost_val = new unsigned[10];
}
@@ -34,6 +42,9 @@
if (cost) {
delete [] cost;
}
+ if (vcost) {
+ delete [] vcost;
+ }
if (cost_val)
delete [] cost_val;
}
More information about the cfe-commits
mailing list