diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-09-28 22:21:42 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-09-28 22:21:42 +0000 |
commit | 13d6b71929ac2b4b90e1da41e9e41ad1e9b0c15e (patch) | |
tree | b7dc595fa63857ec65017573d005aa9ae06d911a /clang/lib | |
parent | 62b379873d03911c9d8061411088a1298b37d93a (diff) | |
download | bcm5719-llvm-13d6b71929ac2b4b90e1da41e9e41ad1e9b0c15e.tar.gz bcm5719-llvm-13d6b71929ac2b4b90e1da41e9e41ad1e9b0c15e.zip |
-Wreceiver-is-weak: rephrase warning text and add a suggestion Note.
New output:
warning: weak property may be unpredictably set to nil
note: property declared here
note: assign the value to a strong variable to keep the object alive
during use
<rdar://problem/12277204>
llvm-svn: 164857
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 58e28a94044..f3ae25ed482 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -1341,21 +1341,22 @@ static void DiagnoseARCUseOfWeakReceiver(Sema &S, Expr *Receiver) { } } - if (T.getObjCLifetime() == Qualifiers::OCL_Weak) { - S.Diag(Loc, diag::warn_receiver_is_weak) - << ((!PDecl && !GDecl) ? 0 : (PDecl ? 1 : 2)); - if (PDecl) - S.Diag(PDecl->getLocation(), diag::note_property_declare); - else if (GDecl) - S.Diag(GDecl->getLocation(), diag::note_method_declared_at) << GDecl; - return; + if (T.getObjCLifetime() != Qualifiers::OCL_Weak) { + if (!PDecl) + return; + if (!(PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)) + return; } - - if (PDecl && - (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)) { - S.Diag(Loc, diag::warn_receiver_is_weak) << 1; + + S.Diag(Loc, diag::warn_receiver_is_weak) + << ((!PDecl && !GDecl) ? 0 : (PDecl ? 1 : 2)); + + if (PDecl) S.Diag(PDecl->getLocation(), diag::note_property_declare); - } + else if (GDecl) + S.Diag(GDecl->getLocation(), diag::note_method_declared_at) << GDecl; + + S.Diag(Loc, diag::note_arc_assign_to_strong); } /// HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an |