From 48ddcf2cb57caf57f8e1f1029f39fc490de74e08 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sat, 25 Aug 2012 07:11:29 +0000 Subject: Fix a CodeGen bug where we would skip zero-initialization for array new with a non-trivial constructor. Pointed out in PR13380. llvm-svn: 162643 --- clang/lib/CodeGen/CGExprCXX.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 0faf98032c1..17e2bc18744 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -956,7 +956,6 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E, if (E->isArray()) { if (const CXXConstructExpr *CCE = dyn_cast_or_null(Init)){ CXXConstructorDecl *Ctor = CCE->getConstructor(); - bool RequiresZeroInitialization = false; if (Ctor->isTrivial()) { // If new expression did not specify value-initialization, then there // is no initialization. @@ -969,13 +968,11 @@ static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E, EmitZeroMemSet(CGF, ElementType, NewPtr, AllocSizeWithoutCookie); return; } - - RequiresZeroInitialization = true; } CGF.EmitCXXAggrConstructorCall(Ctor, NumElements, NewPtr, CCE->arg_begin(), CCE->arg_end(), - RequiresZeroInitialization); + CCE->requiresZeroInitialization()); return; } else if (Init && isa(Init) && CGF.CGM.getTypes().isZeroInitializable(ElementType)) { -- cgit v1.2.3