Re: Static Analyzer Question
Re: Static Analyzer Question
- Subject: Re: Static Analyzer Question
- From: Greg Parker <email@hidden>
- Date: Tue, 29 Sep 2009 17:28:08 -0700
On Sep 29, 2009, at 5:12 PM, Steve Cronin wrote:
"…. Object with +0 retain counts returned to caller where a +1
(owning) retain count is expected"
this is shown at the end of a particular method.
The deal is that, over time, I have isolated this method and at this
moment there are NO methods which call it.
I cannot leave it like this - this isolation is a result of honing
in on the Clang issue...
A very common pattern for my application looks like this:
+ (NSString *) fooBar {
NSString *result = @"";
…..
if (x) {
result = @"1";
...
} else {
result = @"2";
}
return result;
}
Yes this is a class method - I use this pattern for both class and
instance methods.
This is the only method that Clang has an issue with…
Why does Clang believe that an 'owning retain count is expected' if
the method is never called?
Why is Clang picking on this one method which mirrors the mechanics
of so many others?
The static analyzer tries to enforce Cocoa's memory management
convention, where the retain-edness of the return value depends on the
name of the method. By that convention, if the method name contains
"new" or "copy" or "alloc" then the return value is retained and the
caller is expected to release it; otherwise the return value is
autoreleased and the caller is not expected to release it.
What exactly is the name of the method the analyzer complains about?
I'm guessing that name includes "new" or "copy" or "alloc", and the
similar methods that the analyzer likes do not.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden