Static Analyzer

Hello!

I have a problem with the Static Analyzer. I have the following class:

@interface MyClass : NSObject {}

  • (CFDateRef) returnsCFRetainedCF CF_RETURNS_RETAINED;
    @end

@implementation MyClass

  • (CFDateRef) returnsCFRetainedCF {
    return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // Potential leak of an object…
    }
    @end

When I run the Static Analyzer on this I get an issue “Potential leak of an object allocated on line n”. I have tried to remove the issue with the “CF_RETURNS_RETAINED” in the interface declaration (as you can see above) but that does not work. It works fine if I make a cast and return the object as an objC object (NSDate*).

I’m running XCode 3.2 on Mac OS 10.6 Beta (IDE/Core: 1602.0, ToolSupport: 1591.0). I have a small XCode project if anyone wants to look closer at my problem: http://oops.se/StaticAnalyzerTest.zip

Is this how it should work or is this a bug? Any information would be very helpful.

Thanks and best regards,

  • Martin

AFAK, Xcode 3.2 is under NDA and cannot be discussed publicly.
That said, it does not include that last build of clang, and I don’t think the version distributed with Xcode 3.2 supports CF_RETURNS_RETAINED.
Try with an up to date version of the analyzer.

6 jul 2009 kl. 16.15 skrev Jean-Daniel Dupas:

Hi Martin,

Please file a bug report with self-contained Xcode project that exhibits the false positive. I’ll then looking at fixing it ASAP. Since this issue is with the analyzer itself, it is fine to use Bugzilla. You can also file the bug at bugreporter.apple.com and it will get routed to me. Specific issues with Xcode 3.2 or Snow Leopard should not be discussed on this list until it is publicly released.

Ted

6 jul 2009 kl. 19.06 skrev Ted Kremenek:

Hi Martin,

Please file a bug report with self-contained Xcode project that exhibits the false positive. I’ll then looking at fixing it ASAP. Since this issue is with the analyzer itself, it is fine to use Bugzilla. You can also file the bug at bugreporter.apple.com and it will get routed to me. Specific issues with Xcode 3.2 or Snow Leopard should not be discussed on this list until it is publicly released

Ok, sorry about my reference to XCode. I’m now only talking about the “checker-0.212.tar.bz2” version… I have filed a bug report at bugreporter.apple.com.

Thanks,

  • Martin