Issue count discrepancy in scan-build for Objective-C

Hi:

I’m curious why I see a discrepancy in the issue count reported from xcode 4.2 vs. scan-build (checker-258). Xcode has found 29 issues while scan-build (258) found 7; most notable are the difference in memory leaks.

Here is how I run scan-build:
scan-build --use-cc=which clang -k -o scan-reports xcodebuild -target MyTarget -project myproject.xcodeproj -sdk iphonesimulator5.0 -configuration Debug clean build

Thanks in advance.

Regards,

Jason Leach
Fullboar Creative Corp.
jason.leach@fullboar.ca
http://fullboar.ca/

t. +1.604.800.0266 ext 101
c. +1.604.318.3939
f. +1.604.800.0266

Hi Jason,

If you use the ‘set-xcode-analyzer’ script to change which ‘clang’ is used directly by Xcode for static analysis, do you get the same number of issues within Xcode as you do for scan-build? Essentially, if you use the clang in checker-258 directly within Xcode, do you get the same results as when using scan-build? If so, this is a scan-build issue. If not, this is a potential regression in the analyzer itself.

Cheers,
Ted

Hi Ted,

Good idea for a test. It actually finds more issues so Xcode clearly knows how to run the tool better than me. I notice that with the command line execution I see some issues that make me think it is using the old (not modern) runtime:

Example:

error: synthesized property ‘persistentStoreCoordinator’ must either be named the same as a compatible ivar or must explicitly name an ivar
@synthesize persistentStoreCoordinator;
^
5 errors generated.

Any tips on troubleshooting would be appreciated.

J.

Hi Ted,

Good idea for a test. It actually finds more issues so Xcode clearly knows how to run the tool better than me. I notice that with the command line execution I see some issues that make me think it is using the old (not modern) runtime:

Example:
error: synthesized property 'persistentStoreCoordinator' must either be named the same as a compatible ivar or must explicitly name an ivar
@synthesize persistentStoreCoordinator;

You may want to check the compiler setting. Since modern runtime is the default, you may be compiling for the 32-bit architecture (-arch i386) which
uses the old runtime.

- fariborz