[cfe-dev] [PATCH] Check missing or extra releases of ivars in dealloc

Ted Kremenek kremenek at apple.com
Tue Oct 28 21:36:58 PDT 2008

On Oct 27, 2008, at 5:55 AM, Nikita Zhuk wrote:

> On 25.10.2008, at 5.55, Ted Kremenek wrote:
>> Hi Nikita,
>> Overall this patch looks really great.  At some point it would be  
>> good for it to utilize the logic from the retain/release checker to  
>> see if an ivar has been released instead of walking the AST to see  
>> if an ivar has been passed a 'release' message.  Not only will this  
>> allow us to handle the many edge cases with syntax (e.g., casts,  
>> parentheses, etc.), it will also allow us to determine if a - 
>> dealloc implementation correctly releases an ivar along every path,  
>> etc.
> Actually, I found one deficiency in my patch but I'm not sure how to  
> fix it. Since I'm only interested in checking 'release' messages  
> sent to ivars of 'readwrite' properties, I check if PD->isReadOnly()  
> returns true. However, if a property is declared as 'readonly' in  
> @interface and then redeclared later as 'readwrite' (in a class  
> extension or in a protocol), PD->isReadOnly() still returns true and  
> some potentially missing releases are not catched by my check. Is  
> there some reusable code in clang which would take property  
> attribute overriding into account and give the the "final" set of  
> attributes, or should I write class extension / protocol property  
> lookup myself?

I'm don't know if we have such a property attribute lookup mechanism  
in place; but having an API that returns the "canonical" attributes  
for a class or protocol would be really useful.  This is something  
fairly fundamental that could be put in the AST library.  Essentially  
it would take as input the ObjCInterfaceDecl and an ASTContext and  
return the canonical attributes.

Steve: You're the expert on the state of properties in the AST.  I  
haven't looked all that much in what we do in Sema with properties  
(where some of these issues might pop up).  Do we have such a thing  
already in place?

More information about the cfe-dev mailing list