]> granicus.if.org Git - clang/commitdiff
ObjectiveC. Fixes a bogus warning of unused backing
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 15 Nov 2013 17:48:00 +0000 (17:48 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 15 Nov 2013 17:48:00 +0000 (17:48 +0000)
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

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/unsued-backing-ivar-warning.m

index 86979a1fe85f34de6a9693820e22e7863116afb4..f44fb3251141d7a86775b925355eef8dd61c890e 100644 (file)
@@ -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;
 }
 
index 2f55efabcd6e7420f89d2810111341a631eb9eb3..c07dea71a7e180e4b45db2a3ab02a8b944528088 100644 (file)
     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