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 | 7d94a9503c90fd26cd41a5cae3831d79e334526f (patch) | |
tree | 554c9536711de8a8f1f77d870c1b1726e01b0e26 /lib/CodeGen/CGExprConstant.cpp | |
parent | f5416bdb75832e0a400cf3b19bd2116d2fed9ebe (diff) |
If a global initializer has a non-trivial destructor it can't be emitted as a constant (even if it has a trivial constructor).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index a358b54fa3..436c41723d 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/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"); |