[cfe-dev] NSAutoreleasePool checker

David Chisnall csdavec at swan.ac.uk
Fri May 27 07:22:01 PDT 2011


Hi Ted,

The problem is that the GC setting is dependent on the current compilation mode, not on the deployment target.  If you are writing a framework that may be compiled in GC or non-GC mode, then you may well be building it and running the analyser in non-GC mode (e.g. for targeting the iPhone), but it would be helpful for the analyser to warn you that you're using the autorelease pool in a non-recommended way.  Someone who grabs your framework for use on another platform may compile it with -fobjc-gc, but not run the analyser, so no one will ever see the message.  

I've just fixed 74 instances of this in the GNUstep code.  Most of the people working on the project are building in non-GC mode, so if they run the analyser, they won't see this warning, but it is something that should be fixed for people who do then build the code with GC enabled.

David

On 27 May 2011, at 15:13, Ted Kremenek wrote:

> Hi David,
> 
> The point of this checker is to find bugs.  Enabling all the time is likely to produce a significant amount of noise on real world code while providing no real value.
> 
> That said, I think there should be a way to opt into the check even if you are in non-GC, but I don't think that turning it on all the time is the right answer.  I'm very skeptical that's what most people would want.
> 
> Ted
> 
> On May 27, 2011, at 3:14 AM, David Chisnall <csdavec at swan.ac.uk> wrote:
> 
>> Hi Everyone,
>> 
>> Currently the NSAutoreleasePool checker in the static analyser is only enabled in GC mode.  Does anyone object if I enable it unconditionally?  Sending -drain instead of -release to autorelease pools works in both GC and non-GC mode, while sending -release is a no-op in GC mode, so it's good style to use -drain always (recent Apple examples use -drain even in non-GC mode).
>> 
>> David
>> _______________________________________________
>> 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