diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-13 19:27:47 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-13 19:27:47 +0000 |
commit | 6814eaa2ccf78481d7dae4aa251decadafd20905 (patch) | |
tree | 5985f638de455c5e9707c0643048c73ed06c0cad /clang/lib/CodeGen/CGCXX.cpp | |
parent | 1fe64cb05955e14324c53b6a4098257765239c72 (diff) | |
download | bcm5719-llvm-6814eaa2ccf78481d7dae4aa251decadafd20905.tar.gz bcm5719-llvm-6814eaa2ccf78481d7dae4aa251decadafd20905.zip |
Code gen for arrady delete operator. Fixes pr5472.
llvm-svn: 88680
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 9b83f001735..c23ad597649 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -521,16 +521,25 @@ CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D, llvm::Value *This) { const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array); assert(CA && "Do we support VLA for destruction ?"); + uint64_t ElementCount = getContext().getConstantArrayElementCount(CA); + llvm::Value* ElementCountPtr = + llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), ElementCount); + EmitCXXAggrDestructorCall(D, ElementCountPtr, This); +} + +/// EmitCXXAggrDestructorCall - calls the default destructor on array +/// elements in reverse order of construction. +void +CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D, + llvm::Value *UpperCount, + llvm::Value *This) { llvm::Value *One = llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), 1); - uint64_t ElementCount = getContext().getConstantArrayElementCount(CA); // Create a temporary for the loop index and initialize it with count of // array elements. llvm::Value *IndexPtr = CreateTempAlloca(llvm::Type::getInt64Ty(VMContext), "loop.index"); // Index = ElementCount; - llvm::Value* UpperCount = - llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), ElementCount); Builder.CreateStore(UpperCount, IndexPtr, false); // Start the loop with a block that tests the condition. @@ -574,7 +583,7 @@ CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D, EmitBlock(AfterFor, true); } -/// EmitCXXAggrDestructorCall - Generates a helper function which when invoked, +/// GenerateCXXAggrDestructorHelper - Generates a helper function which when invoked, /// calls the default destructor on array elements in reverse order of /// construction. llvm::Constant * |