summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-11-15 17:48:00 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-11-15 17:48:00 +0000
commit4417498c9f31829c1c2e0b0a99db13420e988746 (patch)
tree3c79458b5e9d38efdea25c3f9b194bfe9628e934
parent9b58b6e3ca8a2b3224fb89a2051e756fee88ed80 (diff)
downloadclang-4417498c9f31829c1c2e0b0a99db13420e988746.tar.gz
clang-4417498c9f31829c1c2e0b0a99db13420e988746.tar.bz2
clang-4417498c9f31829c1c2e0b0a99db13420e988746.tar.xz
ObjectiveC. Fixes a bogus warning of unused backing
ivar when property belongs to a super class and currnt class happens to have a method with same name as property. // rdar//15473432 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194830 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclObjC.cpp11
-rw-r--r--test/SemaObjC/unsued-backing-ivar-warning.m25
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 86979a1fe8..f44fb32511 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -3510,8 +3510,17 @@ Sema::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
Method = IDecl->lookupMethod(Method->getSelector(), true);
if (!Method || !Method->isPropertyAccessor())
return 0;
- if ((PDecl = Method->findPropertyDecl()))
+ if ((PDecl = Method->findPropertyDecl())) {
+ if (!PDecl->getDeclContext())
+ return 0;
+ // Make sure property belongs to accessor's class and not to
+ // one of its super classes.
+ if (const ObjCInterfaceDecl *CID =
+ dyn_cast<ObjCInterfaceDecl>(PDecl->getDeclContext()))
+ if (CID != IDecl)
+ return 0;
return PDecl->getPropertyIvarDecl();
+ }
return 0;
}
diff --git a/test/SemaObjC/unsued-backing-ivar-warning.m b/test/SemaObjC/unsued-backing-ivar-warning.m
index 2f55efabcd..c07dea71a7 100644
--- a/test/SemaObjC/unsued-backing-ivar-warning.m
+++ b/test/SemaObjC/unsued-backing-ivar-warning.m
@@ -49,3 +49,28 @@
okIvar = newT;
}
@end
+
+// rdar://15473432
+typedef char BOOL;
+@interface CalDAVServerVersion {
+ BOOL _supportsTimeRangeFilterWithoutEndDate;
+}
+@property (nonatomic, readonly,nonatomic) BOOL supportsTimeRangeFilterWithoutEndDate;
+@end
+
+@interface CalDAVConcreteServerVersion : CalDAVServerVersion {
+}
+@end
+
+@interface CalendarServerVersion : CalDAVConcreteServerVersion
+@end
+
+@implementation CalDAVServerVersion
+@synthesize supportsTimeRangeFilterWithoutEndDate=_supportsTimeRangeFilterWithoutEndDate;
+@end
+
+@implementation CalendarServerVersion
+-(BOOL)supportsTimeRangeFilterWithoutEndDate {
+ return 0;
+}
+@end