aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprAgg.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-20 15:39:01 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-20 15:39:01 +0000
commite9979484670ca2b528146d1b681e149fdc29f7cc (patch)
tree05526d45fbba0ed63946a65259dcdbaf79c22afe /lib/CodeGen/CGExprAgg.cpp
parente03db98d67111ebf7622d9086951aacc24406b66 (diff)
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++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104227 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
-rw-r--r--lib/CodeGen/CGExprAgg.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 5a1516cf32..b467dbc875 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/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;
}
}