What I meant was, this is essentially looking for a method which matches PDecl->getSetterName(). Could we just implement this function as: -- bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const { return lookupMethod(PDecl->getSetterName()) != NULL; } -- Then we only have to worry about making lookupMethod fast. Similarly, I think there are other checks we do on properties that could be implemented in this fashion.
Did that make more sense? - Daniel On Sat, Jan 10, 2009 at 11:27 AM, Fariborz Jahanian <fjahan...@apple.com> wrote: > I am not sure what you mean. This is how we look up any instance methods in > general. > I don't know what you mean by majority of semantic checks. Majority of > semantics > check for property assignment syntax is than by the caller. Are you saying > to move all that in > one function and call that? If so, I will add a FIXME syntax. But I don't > think it is necessary. > > - Fariborz > > > On Jan 10, 2009, at 11:13 AM, Daniel Dunbar wrote: > >> Hi Fariborz, >> >> Could we simply implement this check in terms of a more general >> function by doing a lookup to see if the setter method is defined? My >> thought is that if we can implement the majority of semantic checks in >> terms of that function, then there will only be one thing we need to >> focus on making efficient. >> >> - Daniel >> >> On Sat, Jan 10, 2009 at 10:43 AM, Fariborz Jahanian <fjahan...@apple.com> >> wrote: >>> >>> Author: fjahanian >>> Date: Sat Jan 10 12:43:55 2009 >>> New Revision: 62028 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=62028&view=rev >>> Log: >>> Explicit declaration of property setters over-ride >>> prohibition of 'readonly' properties in an assignment. >>> >>> Added: >>> cfe/trunk/test/SemaObjC/property-user-setter.m >>> Modified: >>> cfe/trunk/lib/AST/DeclObjC.cpp >>> >>> Modified: cfe/trunk/lib/AST/DeclObjC.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=62028&r1=62027&r2=62028&view=diff >>> >>> >>> ============================================================================== >>> --- cfe/trunk/lib/AST/DeclObjC.cpp (original) >>> +++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Jan 10 12:43:55 2009 >>> @@ -257,7 +257,9 @@ >>> /// >>> bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const >>> { >>> - if (!PDecl->isReadOnly()) >>> + // Even if property is ready only, if interface has a user defined >>> setter, >>> + // it is not considered read only. >>> + if (!PDecl->isReadOnly() || getInstanceMethod(PDecl->getSetterName())) >>> return false; >>> >>> // Main class has the property as 'readonly'. Must search >>> @@ -265,6 +267,10 @@ >>> // attribute has been over-ridden to 'readwrite'. >>> for (ObjCCategoryDecl *Category = getCategoryList(); >>> Category; Category = Category->getNextClassCategory()) { >>> + // Even if property is ready only, if a category has a user defined >>> setter, >>> + // it is not considered read only. >>> + if (Category->getInstanceMethod(PDecl->getSetterName())) >>> + return false; >>> ObjCPropertyDecl *P = >>> Category->FindPropertyDeclaration(PDecl->getIdentifier()); >>> if (P && !P->isReadOnly()) >>> >>> Added: cfe/trunk/test/SemaObjC/property-user-setter.m >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-user-setter.m?rev=62028&view=auto >>> >>> >>> ============================================================================== >>> --- cfe/trunk/test/SemaObjC/property-user-setter.m (added) >>> +++ cfe/trunk/test/SemaObjC/property-user-setter.m Sat Jan 10 12:43:55 >>> 2009 >>> @@ -0,0 +1,25 @@ >>> +// RUN: clang -fsyntax-only -verify %s >>> + >>> +...@interface I0 >>> +...@property(readonly) int x; >>> +...@property(readonly) int y; >>> +...@property(readonly) int z; >>> +-(void) setY: (int) y0; >>> +...@end >>> + >>> +...@interface I0 (Cat0) >>> +-(void) setX: (int) a0; >>> +...@end >>> + >>> +...@implementation I0 >>> +...@dynamic x; >>> +...@dynamic y; >>> +...@dynamic z; >>> +-(void) setY: (int) y0{} >>> + >>> +-(void) im0 { >>> + self.x = 0; >>> + self.y = 2; >>> + self.z = 2; // expected-error {{assigning to property with 'readonly' >>> attribute not allowed}} >>> +} >>> +...@end >>> >>> >>> _______________________________________________ >>> cfe-commits mailing list >>> cfe-commits@cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >>> > > _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits