aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--lib/CodeGen/CGExprCXX.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index eb984d3cbb..8c67b8bba6 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -320,8 +320,14 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
InitType = getContext().getBaseElementType(Array);
const CXXRecordDecl *RD =
cast<CXXRecordDecl>(InitType->getAs<RecordType>()->getDecl());
- if (RD->hasTrivialConstructor())
+ if (RD->hasTrivialConstructor()) {
+ // The constructor is trivial, but we may still need to zero-initialize
+ // the class.
+ if (E->requiresZeroInitialization())
+ EmitNullInitialization(Dest, E->getType());
+
return;
+ }
}
// Code gen optimization to eliminate copy constructor and return
// its first argument instead, if in fact that argument is a temporary