[cfe-commits] r62028 - in /cfe/trunk: lib/AST/DeclObjC.cpp test/SemaObjC/property-user-setter.m

Fariborz Jahanian fjahanian at apple.com
Sat Jan 10 11:27:27 PST 2009


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 <fjahanian at 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
>> +
>> + at interface I0
>> + at property(readonly) int x;
>> + at property(readonly) int y;
>> + at property(readonly) int z;
>> +-(void) setY: (int) y0;
>> + at end
>> +
>> + at interface I0 (Cat0)
>> +-(void) setX: (int) a0;
>> + at end
>> +
>> + at implementation I0
>> + at dynamic x;
>> + at dynamic y;
>> + at 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}}
>> +}
>> + 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