diff options
author | John McCall <rjmccall@apple.com> | 2011-07-13 08:09:46 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-07-13 08:09:46 +0000 |
commit | fbf780a9d1dbb191fc40c8af967c590e08724b74 (patch) | |
tree | b7d1b2dfad85ba0306fcf795c1fc140f51394a2b /lib/CodeGen/CGExprCXX.cpp | |
parent | dd376cae98ce4d0ab92c90d3e9c01ee19e919f44 (diff) |
Okay, that rule about zero-length arrays applies to destroying
them, too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index e3c6a8f978..e8ed84955e 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -1364,26 +1364,16 @@ static void EmitArrayDelete(CodeGenFunction &CGF, if (QualType::DestructionKind dtorKind = elementType.isDestructedType()) { assert(numElements && "no element count for a type with a destructor!"); - // It's legal to allocate a zero-length array, but emitArrayDestroy - // won't handle that correctly, so we need to check that here. - llvm::Value *iszero = - CGF.Builder.CreateIsNull(numElements, "delete.isempty"); - - // We'll patch the 'true' successor of this to lead to the end of - // the emitArrayDestroy loop. - llvm::BasicBlock *destroyBB = CGF.createBasicBlock("delete.destroy"); - llvm::BranchInst *br = - CGF.Builder.CreateCondBr(iszero, destroyBB, destroyBB); - CGF.EmitBlock(destroyBB); - llvm::Value *arrayEnd = CGF.Builder.CreateInBoundsGEP(deletedPtr, numElements, "delete.end"); + + // Note that it is legal to allocate a zero-length array, and we + // can never fold the check away because the length should always + // come from a cookie. CGF.emitArrayDestroy(deletedPtr, arrayEnd, elementType, CGF.getDestroyer(dtorKind), + /*checkZeroLength*/ true, CGF.needsEHCleanup(dtorKind)); - - assert(CGF.Builder.GetInsertBlock()->empty()); - br->setSuccessor(0, CGF.Builder.GetInsertBlock()); } // Pop the cleanup block. |