diff options
author | Anders Carlsson <andersca@mac.com> | 2010-02-05 05:19:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-02-05 05:19:42 +0000 |
commit | ecac409cb0a26fb79ecb0ff15e2e446daa121371 (patch) | |
tree | 3d53d5b8d50e1321b3bf0823dc5607c89aeef0d8 /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | f668204a6aec3b5a563dd074a88fdf3496a9e314 (diff) | |
download | bcm5719-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.cpp | 11 |
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"); |