aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-20 16:57:37 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-20 16:57:37 +0000
commit452b7f22d75d1838df72653dcaacbf92b6c34e71 (patch)
treec5288593203233dc98c770fb8adcfe15bc39dd1e /lib/CodeGen/CGExprCXX.cpp
parent0930b6e6c819aa5c871c4cfb7f8f4bb5a15af5af (diff)
Fix a major regression with value-initialization of class types with
trivial default constructors. We're weren't zero-initializing them, which manifested as <rdar://problem/8320532> (a regression in the GCC test suite) and is likely to have caused significant other breakage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111650 91177308-0d34-0410-b5e6-96231b3b80d8
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