aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-06-22 16:12:01 +0000
committerDouglas Gregor <dgregor@apple.com>2011-06-22 16:12:01 +0000
commitd7b23167763f43d3e76b0de26141b1e52613ee3c (patch)
tree71644c427688cfee6c871d4b65502cb81fbe0964 /lib/Sema/SemaInit.cpp
parentb4b7b5034bb8304ed03416635bf64c75c39889fc (diff)
When binding a reference to an Automatic Reference Counting temporary,
retain/release the temporary object appropriately. Previously, we would only perform the retain/release operations when the reference would extend the lifetime of the temporary, but this does the wrong thing across calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index e93d2d83cd..15007ef7c6 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -4084,6 +4084,13 @@ InitializationSequence::Perform(Sema &S,
Entity.getType().getNonReferenceType(),
CurInit.get(),
Entity.getType()->isLValueReferenceType());
+
+ // If we're binding to an Objective-C object that has lifetime, we
+ // need cleanups.
+ if (S.getLangOptions().ObjCAutoRefCount &&
+ CurInit.get()->getType()->isObjCLifetimeType())
+ S.ExprNeedsCleanups = true;
+
break;
case SK_ExtraneousCopyToTemporary: