summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-02-05 05:19:42 +0000
committerAnders Carlsson <andersca@mac.com>2010-02-05 05:19:42 +0000
commitecac409cb0a26fb79ecb0ff15e2e446daa121371 (patch)
tree3d53d5b8d50e1321b3bf0823dc5607c89aeef0d8 /clang/lib/CodeGen/CGExprConstant.cpp
parentf668204a6aec3b5a563dd074a88fdf3496a9e314 (diff)
downloadbcm5719-llvm-ecac409cb0a26fb79ecb0ff15e2e446daa121371.tar.gz
bcm5719-llvm-ecac409cb0a26fb79ecb0ff15e2e446daa121371.zip
If a global initializer has a non-trivial destructor it can't be emitted as a constant (even if it has a trivial constructor).
llvm-svn: 95363
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index a358b54fa3c..436c41723d7 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -675,9 +675,18 @@ public:
if (!E->getConstructor()->isTrivial())
return 0;
+ QualType Ty = E->getType();
+
+ const CXXRecordDecl *RD =
+ cast<CXXRecordDecl>(Ty->getAs<RecordType>()->getDecl());
+
+ // If the class doesn't have a trivial destructor, we can't emit it as a
+ // constant expr.
+ if (!RD->hasTrivialDestructor())
+ return 0;
+
// Only copy and default constructors can be trivial.
- QualType Ty = E->getType();
if (E->getNumArgs()) {
assert(E->getNumArgs() == 1 && "trivial ctor with > 1 argument");
OpenPOWER on IntegriCloud