From a1f8571e849eb935f27f61087a22d0295b079463 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 19 Dec 2012 18:58:55 +0000 Subject: [PATCH] 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 llvm-svn: 170573 --- clang/lib/Sema/SemaObjCProperty.cpp | 19 ++++++++++++++---- clang/test/SemaObjC/property-category-impl.m | 29 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp index 2857296..a498558 100644 --- a/clang/lib/Sema/SemaObjCProperty.cpp +++ b/clang/lib/Sema/SemaObjCProperty.cpp @@ -1573,12 +1573,23 @@ void Sema::DefaultSynthesizeProperties(Scope *S, Decl *D) { void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, ObjCContainerDecl *CDecl, const SelectorSet &InsMap) { - ObjCContainerDecl::PropertyMap SuperPropMap; - if (ObjCInterfaceDecl *IDecl = dyn_cast(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(CDecl))) + if (ObjCCategoryDecl *C = dyn_cast(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; diff --git a/clang/test/SemaObjC/property-category-impl.m b/clang/test/SemaObjC/property-category-impl.m index 9524c22..be42dea 100644 --- a/clang/test/SemaObjC/property-category-impl.m +++ b/clang/test/SemaObjC/property-category-impl.m @@ -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. +@interface HBSuperclass +@property (nonatomic) char myProperty; +@property (nonatomic) char myProperty2; +@end + +@interface HBClass : HBSuperclass +@end + +@protocol HBProtocol +@property (nonatomic) char myProperty; +@property (nonatomic) char myProperty2; +@end + +@interface HBSuperclass (HBSCategory) +@end + +@implementation HBSuperclass (HBSCategory) +@end + +@interface HBClass (HBCategory) +@end + +@implementation HBClass (HBCategory) +@end -- 2.7.4