[cfe-dev] Static analyser and objc init methods
devlists at shadowlab.org
Thu Oct 30 09:03:34 PDT 2008
Le 30 oct. 08 à 16:43, Shawn Erickson a écrit :
> On Wed, Oct 29, 2008 at 3:37 PM, Jean-Daniel Dupas
> <devlists at shadowlab.org> wrote:
>> I think the memory leak analyser need a special semantic for objc
>> class initializer methods.
>> Generaly, an initializer returns self, but in some case, it may
>> to return something else (or throw an exception)
>> In these cases, 'self' must be release before the method returns else
>> it will leaks. (http://www.cocoabuilder.com/archive/message/cocoa/2008/2/11/198549
>> Additionaly, if an init method returns a new object, this object
>> should be returns with a retain count to 1.
> I don't think that is a correct requirement, at least not directly
> as stated.
> It could be an application life long object with a possibly a MAX_INT
> retain count. It could be an object with a retain count greater then 1
> but with deferred releases (added to the current autorelease pool one
> or more times).
You're right. It should not be exactly one.
Do you think the following assumption is right ?
Clang should considere init methods that does not return self just
like it does for "+alloc, -create… or -copy…" method family.
More information about the cfe-dev