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

Ken Ferry kenferry at gmail.com
Thu Oct 30 00:16:08 PDT 2008

Hi Louis,

This sounds like a great thing to check, but it isn't an error for a  
class to have multiple designated initializers. NSView's designated  
initializers are -initWithFrame: and -initWithCoder:, for example.


On Oct 29, 2008, at 11:06 PM, Nikita Zhuk <nikita at zhuk.fi> wrote:

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

More information about the cfe-dev mailing list