diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-01-02 22:42:09 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-01-02 22:42:09 +0000 |
commit | c0861a05e6f673c3827b09c180714f377b24396c (patch) | |
tree | 90b922012ac8fb162ad9ca7c562003783faeb101 /lib/Sema/SemaDeclObjC.cpp | |
parent | a6ce0a88cd3dad929cbe003987acce80c3781666 (diff) |
ObjectiveC. Remove false positive warning for missing property
backing ivar by not issuing this warning if ivar is referenced
somewhere and accessor makes method calls. // rdar://15727325
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198367 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 7024cf6cb3..edbd714184 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -3521,8 +3521,13 @@ void Sema::DiagnoseUnusedBackingIvarInAccessor(Scope *S) { const ObjCPropertyDecl *PDecl; const ObjCIvarDecl *IV = GetIvarBackingPropertyAccessor(CurMethod, PDecl); if (IV && !IV->getBackingIvarReferencedInAccessor()) { - Diag(getCurMethodDecl()->getLocation(), diag::warn_unused_property_backing_ivar) - << IV->getDeclName(); - Diag(PDecl->getLocation(), diag::note_property_declare); + // Do not issue this warning if backing ivar is used somewhere and accessor + // implementation makes a call to a method. This is to prevent false positive in + // some corner cases. + if (!IV->isReferenced() || !CurMethod->getMethodCallsMethod()) { + Diag(getCurMethodDecl()->getLocation(), diag::warn_unused_property_backing_ivar) + << IV->getDeclName(); + Diag(PDecl->getLocation(), diag::note_property_declare); + } } } |