diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-05-20 15:39:01 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-05-20 15:39:01 +0000 |
| commit | f22101a0599ea94b71f43446e24db90bdcff4924 (patch) | |
| tree | 04c7936a95bc44631e04139f95682cfc72a5aaf0 /clang/lib/CodeGen | |
| parent | 02ccd28a92b1b3465fc2102ada983709e5ed407d (diff) | |
| download | bcm5719-llvm-f22101a0599ea94b71f43446e24db90bdcff4924.tar.gz bcm5719-llvm-f22101a0599ea94b71f43446e24db90bdcff4924.zip | |
Assert that we do not try to memcpy a non-POD class type in C++. This
particular issue was the cause of the Boost.Interprocess failures, and
in general will lead to horrendous, hard-to-diagnose miscompiles. The
assertion itself has survives self-host and a full Boost build, so we
are close to eradicating this problem in C++.
Note that the assertion is *not* turned on for Objective-C++, where we
still have problems with introducing memcpy's of non-POD class
types. That part of the assertion will go away as soon as we fix the
known issues in Objective-C++.
llvm-svn: 104227
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 5a1516cf32a..b467dbc875c 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -760,7 +760,13 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr, // Ignore empty classes in C++. if (getContext().getLangOptions().CPlusPlus) { if (const RecordType *RT = Ty->getAs<RecordType>()) { - if (cast<CXXRecordDecl>(RT->getDecl())->isEmpty()) + CXXRecordDecl *Record = cast<CXXRecordDecl>(RT->getDecl()); + assert((Record->hasTrivialCopyConstructor() || + Record->hasTrivialCopyAssignment() || + /*FIXME!*/getContext().getLangOptions().CPlusPlus) && + "Trying to aggregate-copy a type without a trivial copy " + "constructor or assignment operator"); + if (Record->isEmpty()) return; } } |

