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

Jordan Rose jordan_rose at apple.com
Wed Dec 19 11:02:51 PST 2012


How about this case?

> @protocol Foo
> @property id foo
> @end
> 
> @interface FooParent
> - (id)foo;
> - (void)setFoo:(id)foo;
> @end
> 
> @interface Foo : FooParent <Foo>
> @end

(The opposite case should be handled by a property implicitly defining its accessors.)
Jordan


On Dec 19, 2012, at 10:58 , Fariborz Jahanian <fjahanian at apple.com> wrote:

> 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
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list