aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-08-03 07:02:44 +0000
committerJohn McCall <rjmccall@apple.com>2011-08-03 07:02:44 +0000
commitfc4b191b07df309d95aefae39f4cf7c456c91afa (patch)
treee9b311e771c4d2a51ed42def933ace04f0014c50 /lib/Sema/SemaExprCXX.cpp
parent194f06a476d299a7a70e5ff1d152f5895dc0a76c (diff)
In ARC, don't try to reclaim the result of a call to performSelector
unless done in a context where the value is used retained. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136769 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r--lib/Sema/SemaExprCXX.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 0061db9730..ef4944ec35 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -4067,21 +4067,24 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) {
// actual method. FIXME: we should infer retention by selector in
// cases where we don't have an actual method.
} else {
- Decl *D = 0;
+ ObjCMethodDecl *D = 0;
if (ObjCMessageExpr *Send = dyn_cast<ObjCMessageExpr>(E)) {
D = Send->getMethodDecl();
} else {
CastExpr *CE = cast<CastExpr>(E);
- // FIXME. What other cast kinds to check for?
- if (CE->getCastKind() == CK_ObjCProduceObject ||
- CE->getCastKind() == CK_LValueToRValue)
- return MaybeBindToTemporary(CE->getSubExpr());
assert(CE->getCastKind() == CK_GetObjCProperty);
const ObjCPropertyRefExpr *PRE = CE->getSubExpr()->getObjCProperty();
D = (PRE->isImplicitProperty() ? PRE->getImplicitPropertyGetter() : 0);
}
ReturnsRetained = (D && D->hasAttr<NSReturnsRetainedAttr>());
+
+ // Don't do reclaims on performSelector calls; despite their
+ // return type, the invoked method doesn't necessarily actually
+ // return an object.
+ if (!ReturnsRetained &&
+ D && D->getMethodFamily() == OMF_performSelector)
+ return Owned(E);
}
ExprNeedsCleanups = true;