diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-20 16:57:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-20 16:57:37 +0000 |
commit | e3b3464d4e525c4ba1ff07329bfc7d0e2cc4f684 (patch) | |
tree | f0d9c04f76b17137cfa7b7bb6e034460ddafc59d /clang/lib/CodeGen/CGExprCXX.cpp | |
parent | 2fb75f0455d47bec2ffce439591722da4edf3cc0 (diff) | |
download | bcm5719-llvm-e3b3464d4e525c4ba1ff07329bfc7d0e2cc4f684.tar.gz bcm5719-llvm-e3b3464d4e525c4ba1ff07329bfc7d0e2cc4f684.zip |
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.
llvm-svn: 111650
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index eb984d3cbb3..8c67b8bba61 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/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 |