diff options
author | Anders Carlsson <andersca@mac.com> | 2010-02-05 18:38:45 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-02-05 18:38:45 +0000 |
commit | 2ca4f633b21c65e1a4edc2405a768d7f5db564eb (patch) | |
tree | b603c77d74a911231108bc2d06b4af97bfbe3fb0 /lib/CodeGen/CGExprConstant.cpp | |
parent | 16c4f3c7d44289e30f5066dce7ce9efe7ff67bbc (diff) |
Fix the bug that was breaking self-host, and re-land the static ctor fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index a358b54fa3..dca09feebc 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -675,9 +675,20 @@ public: if (!E->getConstructor()->isTrivial()) return 0; + QualType Ty = E->getType(); + + // FIXME: We should not have to call getBaseElementType here. + const RecordType *RT = + CGM.getContext().getBaseElementType(Ty)->getAs<RecordType>(); + const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->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"); |