[cfe-dev] Additional annotations for static analysis (Objective C designated initializers)

Nikita Zhuk nikita at zhuk.fi
Wed Oct 29 23:06:35 PDT 2008


On 30.10.2008, at 7.27, Louis Gerbarg wrote:

> Assuming people are okay with this, it seems like it should be pretty
> trivial to extend checker so that it actually can evaluate the rules
> for designated initializers
> <http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_13_section_3.html 
> >.
> While it does require annotating headers, marking one method per class
> in my framework headers does not seem prohibitive, and to me this
> feels like the sort of check that would like find lots and lots of
> errors if the system headers were annotated;
>
> Anyway, just thought I would check and see what people thought.


Designated initializer check is something I've been missing for some  
time, and I think this is a great addition. While marking designated  
initializer with an attribute is a nice, explicit way which would  
serve also as documentation of the code, would it be useful to infer  
"designatedness" of init methods in classes which do not use this  
attribute? Any init... method which contains a call to [super init...]  
could be assumed to be a designated initializer. Then same checks  
could be apply to those cases as well (i.e. there must be only one  
designated initializer, it must be invoked by every other init...  
method via 'self' etc).

- Nikita





More information about the cfe-dev mailing list