Thursday, January 22, 2009

LLVM/Clang Static Analyzer

By:
Recently discovered this command line utility for checking for leaks in C and Objective-C programs. It also works on projects built with XCode (iPhone, etc.).

To use, simply download the tar and extract it into a folder. I made a symbolic link from my home directory to this folder for ease of use.

To scan for leaks in an iPhone project built with XCode, using the command line, change to the directory that contains your XCode project and do:

~/checker-0.142/scan-build xcodebuild

assuming ~/checker-0.142 is a symbolic link to your installed path for the tool.

If any leaks are found, you will see an error message on the command line letting you know how to view the report using "scan-view". Once run, you will be redirected to your browser with a URL pointing to your localhost on port 8181 (not sure if this port is dynamic).

The author warns that false positives are possible so take these reports with a grain of salt. At least they may point you to the right line of code to start inspecting things closer.

1 comments:

Leo Efstathiou said...

hi ari,

i apologize for the absolute noobish comment but i cant figure out how to change the directory of my project. i have my source code folder on my desktop. would you mind breaking down the steps a bit more please?

to provide a bit more context: i commissioned an app to be developed on my behalf. i now have all the files, did research and came across clang and want to try it out. i could ask my developer but i am trying to get a handle of things for myself rather than resorting to him for everything.

thanks