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);
Builder.CreateIntCast(NumElements,
llvm::Type::getInt64Ty(VMContext), false,
"count.tmp");
- assert (!Dtor->isVirtual() && "delete [] with virtual dtors NYI");
EmitCXXAggrDestructorCall(Dtor, NumElements, Ptr);
Ptr = AllocatedObjectPtr;
}
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();
COST::COST()
{
cost = new S[3];
+ vcost = new V[4];
cost_val = new unsigned[10];
}
if (cost) {
delete [] cost;
}
+ if (vcost) {
+ delete [] vcost;
+ }
if (cost_val)
delete [] cost_val;
}