summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-13 08:09:46 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-13 08:09:46 +0000
commit97eab0a271b3dd1a50ad543afd645c833915c096 (patch)
tree14015f340031c725c44bf49a88ec97ec3b5a0520 /clang/lib/CodeGen/CGExprCXX.cpp
parent72510f22b4f4f654e0adf4dad32fda73f3480a33 (diff)
downloadbcm5719-llvm-97eab0a271b3dd1a50ad543afd645c833915c096.tar.gz
bcm5719-llvm-97eab0a271b3dd1a50ad543afd645c833915c096.zip
Okay, that rule about zero-length arrays applies to destroying
them, too. llvm-svn: 135038
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index e3c6a8f9789..e8ed84955ea 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/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.
OpenPOWER on IntegriCloud