diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-03 01:20:20 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-03 01:20:20 +0000 |
commit | 16e94af67cd3f184884e83e600f11336d8c87ab3 (patch) | |
tree | d813bf3b743e9caf59b684a032694e7af5a4bad9 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 8bdbb5be19caf5985d8c9407885aea0c14ea2c6e (diff) | |
download | bcm5719-llvm-16e94af67cd3f184884e83e600f11336d8c87ab3.tar.gz bcm5719-llvm-16e94af67cd3f184884e83e600f11336d8c87ab3.zip |
Don't copy or initialize empty classes. Fixes PR7012.
llvm-svn: 102891
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 34b904972f9..d3bf1645a02 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -473,6 +473,14 @@ void CodeGenFunction::ErrorUnsupported(const Stmt *S, const char *Type, } void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty) { + // Ignore empty classes in C++. + if (getContext().getLangOptions().CPlusPlus) { + if (const RecordType *RT = Ty->getAs<RecordType>()) { + if (cast<CXXRecordDecl>(RT->getDecl())->isEmpty()) + return; + } + } + const llvm::Type *BP = llvm::Type::getInt8PtrTy(VMContext); if (DestPtr->getType() != BP) DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp"); |