diff options
author | Anders Carlsson <andersca@mac.com> | 2009-08-16 17:54:29 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-08-16 17:54:29 +0000 |
commit | 2da76936a7d17c3e2274412117ab44a95a093ccb (patch) | |
tree | be1252acd44a757f3ff4df66b90e8331aa633364 | |
parent | 8478ce6d3f2416a694e39f791655a473c3907d62 (diff) |
Only do this for initializers of course.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79197 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index ea534d3b2b..1078bacde5 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -93,15 +93,17 @@ RValue CodeGenFunction::EmitReferenceBindingToExpr(const Expr* E, Val = EmitAnyExprToTemp(E, /*IsAggLocVolatile=*/false, IsInitializer); - // We might have to destroy the temporary variable. - if (const RecordType *RT = E->getType()->getAs<RecordType>()) { - if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) { - if (!ClassDecl->hasTrivialDestructor()) { - const CXXDestructorDecl *Dtor = - ClassDecl->getDestructor(getContext()); + if (IsInitializer) { + // We might have to destroy the temporary variable. + if (const RecordType *RT = E->getType()->getAs<RecordType>()) { + if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) { + if (!ClassDecl->hasTrivialDestructor()) { + const CXXDestructorDecl *Dtor = + ClassDecl->getDestructor(getContext()); - CleanupScope scope(*this); - EmitCXXDestructorCall(Dtor, Dtor_Complete, Val.getAggregateAddr()); + CleanupScope scope(*this); + EmitCXXDestructorCall(Dtor, Dtor_Complete, Val.getAggregateAddr()); + } } } } |