views:

162

answers:

1

I’m using Xcode 3.2.4 and have setup the Clang Static Analyser feature to use a newer build of the binary, as detailed here: http://clang-analyzer.llvm.org/xcode.html

(Basically using the set-xcode-analyzer command line utility to change which copy of the Static Analyser that Xcode uses for Build and Analyze.)

What I can’t figure is how to set that binary to use additional checks, such as -analyzer-check-objc-missing-dealloc when using the binary via Xcode, as detailed here: http://loufranco.com/blog/files/scan-build-better-than-build-analyze.html and in scan-build --help.

    AVAILABLE ANALYSES (multiple analyses may be specified):

 (+) -analyzer-check-dead-stores
     -analyzer-check-llvm-conventions
 (+) -analyzer-check-objc-mem
 (+) -analyzer-check-objc-methodsigs
     -analyzer-check-objc-missing-dealloc
 (+) -analyzer-check-objc-unused-ivars
 (+) -analyzer-check-security-syntactic

 NOTE: "(+)" indicates that an analysis is enabled by default unless one
       or more analysis options are specified

How do you pass in extra options to the binary when used via Xcode?

+1  A: 

Upon further investigation, it seems the best way to do this is to use a couple of entries in the Target Build Info, rather than the set-xcode-analyzer command line tool.

Add a User-defined setting, CC, containing the full path to the newer build of the binary, as follows (note that the /bin/clang on the end of the path):

CC = /Path/To/Folder/With/Clang/checker-244/bin/clang

Then in the Other Warning Flags entry add as many of the additional checks as you want, as follows:

WARNING_CFLAGS = -Xanalyzer -analyzer-check-llvm-conventions -Xanalyzer -analyzer-check-objc-missing-dealloc

Each is preceded by the argument -Xanalyzer which indicates that the next argument should be passed to the analyzer.

More on this can be found here: Mac OS X Developer Tools Manual Page.

Then, when you do a Build and Analyze in Xcode you should be using the external, newer binary running the additional checks.

Andy W
i have done the same thing. my analyzer is working now. but the thing is i m getting an error -lgcc is not found .... what is this ?
g.revolution
No idea what causes it, but after a lot of futtzing around the following additional config settings seem to work for me, stopping that error appearing:
Andy W
RUN_CLANG_STATIC_ANALYZER = NOGCC_VERSION = com.apple.compilers.llvm.clang.1_0.analyzerSDKROOT = iphonesimulator4.1OTHER_CFLAGS = -D__IPHONE_OS_VERSION_MIN_REQUIRED=040100
Andy W