summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-01-02 22:42:09 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-01-02 22:42:09 +0000
commit5b3105d2cb1931fc5a271dc7f59c5adb4e58ca01 (patch)
treefef1cbdb882cfe9d0c835fd1ef6a907cf19cb7d2 /clang/lib/Sema
parent44ebc079b91a9846d40eb092da87c537a6b190f5 (diff)
downloadbcm5719-llvm-5b3105d2cb1931fc5a271dc7f59c5adb4e58ca01.tar.gz
bcm5719-llvm-5b3105d2cb1931fc5a271dc7f59c5adb4e58ca01.zip
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 llvm-svn: 198367
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp11
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp4
2 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 7024cf6cb35..edbd7141844 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/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);
+ }
}
}
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index ca67094f80f..8b1befe4f85 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -2643,7 +2643,9 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
}
}
}
-
+ if (ObjCMethodDecl *CurMeth = getCurMethodDecl())
+ CurMeth->setMethodCallsMethod(true);
+
return MaybeBindToTemporary(Result);
}
OpenPOWER on IntegriCloud