[cfe-commits] r170573 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp test/SemaObjC/property-category-impl.m

Fariborz Jahanian fjahanian at apple.com
Wed Dec 19 10:58:55 PST 2012


Author: fjahanian
Date: Wed Dec 19 12:58:55 2012
New Revision: 170573

URL: http://llvm.org/viewvc/llvm-project?rev=170573&view=rev
Log:
objective-C: Don't warn of unimplemented property of protocols in 
category, when those properties will be implemented in category's 
primary class or one of its super classes. // rdar://12568064

Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
    cfe/trunk/test/SemaObjC/property-category-impl.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=170573&r1=170572&r2=170573&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Dec 19 12:58:55 2012
@@ -1573,12 +1573,23 @@
 void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
                                       ObjCContainerDecl *CDecl,
                                       const SelectorSet &InsMap) {
-  ObjCContainerDecl::PropertyMap SuperPropMap;
-  if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl))
-    CollectSuperClassPropertyImplementations(IDecl, SuperPropMap);
+  ObjCContainerDecl::PropertyMap NoNeedToImplPropMap;
+  ObjCInterfaceDecl *IDecl;
+  // Gather properties which need not be implemented in this class
+  // or category.
+  if (!(IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl)))
+    if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl)) {
+      // For categories, no need to implement properties declared in
+      // its primary class (and its super classes) if property is
+      // declared in one of those containers.
+      if ((IDecl = C->getClassInterface()))
+        IDecl->collectPropertiesToImplement(NoNeedToImplPropMap);
+    }
+  if (IDecl)
+    CollectSuperClassPropertyImplementations(IDecl, NoNeedToImplPropMap);
   
   ObjCContainerDecl::PropertyMap PropMap;
-  CollectImmediateProperties(CDecl, PropMap, SuperPropMap);
+  CollectImmediateProperties(CDecl, PropMap, NoNeedToImplPropMap);
   if (PropMap.empty())
     return;
 

Modified: cfe/trunk/test/SemaObjC/property-category-impl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-category-impl.m?rev=170573&r1=170572&r2=170573&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-category-impl.m (original)
+++ cfe/trunk/test/SemaObjC/property-category-impl.m Wed Dec 19 12:58:55 2012
@@ -29,3 +29,32 @@
 
 @implementation MyClass (public)// expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
 @end 
+
+// rdar://12568064
+// No warn of unimplemented property of protocols in category,
+// when those properties will be implemented in category's primary
+// class or one of its super classes.
+ at interface HBSuperclass
+ at property (nonatomic) char myProperty;
+ at property (nonatomic) char myProperty2;
+ at end
+
+ at interface HBClass : HBSuperclass
+ at end
+
+ at protocol HBProtocol
+ at property (nonatomic) char myProperty;
+ at property (nonatomic) char myProperty2;
+ at end
+
+ at interface HBSuperclass (HBSCategory)<HBProtocol>
+ at end
+
+ at implementation HBSuperclass (HBSCategory)
+ at end
+
+ at interface HBClass (HBCategory)<HBProtocol>
+ at end
+
+ at implementation HBClass (HBCategory)
+ at end





More information about the cfe-commits mailing list