aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 5ee3c7b8c9..1b0ba58084 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -1347,6 +1347,9 @@ static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) {
if (!Receiver)
return;
+ if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Receiver))
+ Receiver = OVE->getSourceExpr();
+
Expr *RExpr = Receiver->IgnoreParenImpCasts();
SourceLocation Loc = RExpr->getLocStart();
QualType T = RExpr->getType();
@@ -1369,6 +1372,20 @@ static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) {
}
}
}
+ else if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(RExpr)) {
+ // See if receiver is a method which envokes a synthesized getter
+ // backing a 'weak' property.
+ ObjCMethodDecl *Method = ME->getMethodDecl();
+ if (Method && Method->isSynthesized()) {
+ Selector Sel = Method->getSelector();
+ if (Sel.getNumArgs() == 0)
+ PDecl =
+ S.LookupPropertyDecl(Method->getClassInterface(),
+ Sel.getIdentifierInfoForSlot(0));
+ if (PDecl)
+ T = PDecl->getType();
+ }
+ }
if (T.getObjCLifetime() == Qualifiers::OCL_Weak) {
S.Diag(Loc, diag::warn_receiver_is_weak)