summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-08-16 17:54:29 +0000
committerAnders Carlsson <andersca@mac.com>2009-08-16 17:54:29 +0000
commit3b848940d79ac16d696c12ecdcc79d267f6a2d4e (patch)
tree493ceb5cf088cc1f1d5924777eb7d7b28e4e52fe /clang
parentb80760bd78be450731a39a1c14c1d71918b97e3d (diff)
downloadbcm5719-llvm-3b848940d79ac16d696c12ecdcc79d267f6a2d4e.tar.gz
bcm5719-llvm-3b848940d79ac16d696c12ecdcc79d267f6a2d4e.zip
Only do this for initializers of course.
llvm-svn: 79197
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index ea534d3b2bd..1078bacde50 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/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());
+ }
}
}
}
OpenPOWER on IntegriCloud