r194830 - ObjectiveC. Fixes a bogus warning of unused backing

Fariborz Jahanian fjahanian at apple.com
Fri Nov 15 09:48:01 PST 2013


Author: fjahanian
Date: Fri Nov 15 11:48:00 2013
New Revision: 194830

URL: http://llvm.org/viewvc/llvm-project?rev=194830&view=rev
Log:
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

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=194830&r1=194829&r2=194830&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Nov 15 11:48:00 2013
@@ -3510,8 +3510,17 @@ Sema::GetIvarBackingPropertyAccessor(con
   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;
 }
 

Modified: cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m?rev=194830&r1=194829&r2=194830&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m (original)
+++ cfe/trunk/test/SemaObjC/unsued-backing-ivar-warning.m Fri Nov 15 11:48:00 2013
@@ -49,3 +49,28 @@
     okIvar = newT;
 }
 @end
+
+// rdar://15473432
+typedef char BOOL;
+ at interface CalDAVServerVersion {
+  BOOL _supportsTimeRangeFilterWithoutEndDate;
+}
+ at property (nonatomic, readonly,nonatomic) BOOL supportsTimeRangeFilterWithoutEndDate;
+ at end
+
+ at interface CalDAVConcreteServerVersion : CalDAVServerVersion {
+}
+ at end
+
+ at interface CalendarServerVersion : CalDAVConcreteServerVersion
+ at end
+
+ at implementation CalDAVServerVersion
+ at synthesize supportsTimeRangeFilterWithoutEndDate=_supportsTimeRangeFilterWithoutEndDate;
+ at end
+
+ at implementation CalendarServerVersion
+-(BOOL)supportsTimeRangeFilterWithoutEndDate {
+  return 0;
+}
+ at end





More information about the cfe-commits mailing list