[cfe-commits] r88878 - /cfe/trunk/lib/CodeGen/CGCXX.cpp
Anders Carlsson
andersca at mac.com
Sun Nov 15 15:03:26 PST 2009
Author: andersca
Date: Sun Nov 15 17:03:25 2009
New Revision: 88878
URL: http://llvm.org/viewvc/llvm-project?rev=88878&view=rev
Log:
When generating the deleting ctor, emit a call to delete.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=88878&r1=88877&r2=88878&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sun Nov 15 17:03:25 2009
@@ -1712,16 +1712,36 @@
continue;
DestructedBases.push_back(BaseClassDecl);
}
- if (DestructedBases.empty())
- return;
- for (int i = DestructedBases.size() -1; i >= 0; --i) {
- CXXRecordDecl *BaseClassDecl = DestructedBases[i];
+
+ for (int i = DestructedBases.size(); i > 0; --i) {
+ CXXRecordDecl *BaseClassDecl = DestructedBases[i - 1];
llvm::Value *V = GetAddressCXXOfBaseClass(LoadCXXThis(),
ClassDecl,BaseClassDecl,
/*NullCheckValue=*/false);
EmitCXXDestructorCall(BaseClassDecl->getDestructor(getContext()),
Dtor_Complete, V);
}
+
+ if (DtorType == Dtor_Deleting) {
+ const FunctionDecl *DeleteFD = DD->getOperatorDelete();
+ assert(DeleteFD && "deleting dtor did not have a delete operator!");
+
+ const FunctionProtoType *DeleteFTy =
+ DeleteFD->getType()->getAs<FunctionProtoType>();
+
+ CallArgList DeleteArgs;
+
+ QualType ArgTy = DeleteFTy->getArgType(0);
+ llvm::Value *DeletePtr = Builder.CreateBitCast(LoadCXXThis(),
+ ConvertType(ArgTy));
+ DeleteArgs.push_back(std::make_pair(RValue::get(DeletePtr), ArgTy));
+
+ // Emit the call to delete.
+ EmitCall(CGM.getTypes().getFunctionInfo(DeleteFTy->getResultType(),
+ DeleteArgs),
+ CGM.GetAddrOfFunction(DeleteFD),
+ DeleteArgs, DeleteFD);
+ }
}
void CodeGenFunction::SynthesizeDefaultDestructor(const CXXDestructorDecl *Dtor,
More information about the cfe-commits
mailing list