[cfe-dev] Fast enumeration syntax disables -checker-cfref

Ted Kremenek kremenek at apple.com
Wed Sep 17 10:21:26 PDT 2008

On Sep 17, 2008, at 5:53 AM, Nikita Zhuk wrote:

> Hello,
> There may have been a regression in static analyzer. When analyzing
> Objective-C methods which use the new Obj-C 2.0 'for' syntax (fast
> enumeration), CF reference count checker seems to ignore all leaks.
> I'm using clang rev 56242.
> Here's a test case:
> #import <Foundation/Foundation.h>
> @interface MyClass : NSObject @end
> @implementation MyClass
> -(void)leakingMethod1 {
> 	NSLog(@"%@", [[NSString alloc] init]); // This is reported
> }
> -(void)leakingMethod2 {
> 	for (id obj in [NSArray array])
> 		;
> 	NSLog(@"%@", [[NSString alloc] init]); // This is not reported
> }
> @end
> I've submitted this to bugzilla as bug 2798. Has anyone else
> encountered this problem?

Hi Nikita,

This isn't a regression, just a feature that hasn't been implemented  
yet.  We need to add CFG support for fast enumeration.  The same goes  
for @try, @catch, and @finally.  The analyzer then needs to be  
modified to understand these constructs.  Right now the analyzer will  
skip any function/method for which we cannot build a CFG.


More information about the cfe-dev mailing list