aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-07 06:58:02 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-07 06:58:02 +0000
commit7e5e5f4cc36fe50f46ad76dca7a266434c94f475 (patch)
tree58c8d913ddf2c68a1558a3a0792b3288ee0d04a1 /lib/Sema/SemaExprCXX.cpp
parent72ac120023abb73f3ff9386e193fed55fa9a96e2 (diff)
In ARC, reclaim all return values of retainable type, not just those
where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134605 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r--lib/Sema/SemaExprCXX.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 6ae48dd28c..4c096fe0ec 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -4039,13 +4039,12 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) {
ReturnsRetained = (D && D->hasAttr<NSReturnsRetainedAttr>());
}
- if (ReturnsRetained) {
- ExprNeedsCleanups = true;
- E = ImplicitCastExpr::Create(Context, E->getType(),
- CK_ObjCConsumeObject, E, 0,
- VK_RValue);
- }
- return Owned(E);
+ ExprNeedsCleanups = true;
+
+ CastKind ck = (ReturnsRetained ? CK_ObjCConsumeObject
+ : CK_ObjCReclaimReturnedObject);
+ return Owned(ImplicitCastExpr::Create(Context, E->getType(), ck, E, 0,
+ VK_RValue));
}
if (!getLangOptions().CPlusPlus)