Search This Blog

Wednesday, November 11, 2009

Find Bug with The LLVM/Clang Static Analyzer

Clang Static Analyzer

The Clang Static Analyzer consists of both a source code analysis framework and a standalone tool that finds bugs in C and Objective-C programs. The standalone tool is invoked from the command-line, and is intended to run in tandem with a build of a project or code base.

Both are 100% open source and are part of the Clang project.
Download :http://clang-analyzer.llvm.org/
Mac OS X

* Latest build (Universal binary, 10.5+): checker-227.tar.bz2 (built November 4, 2009)
* Installation and usage

Installation

Since scan-build is a command line tool it makes sense to install it into one of OS X’s pre-defined command line tool locations. We’ll put it in /usr/local/bin.

  1. Make sure that you’ve expanded checker-NN.tar.gz to your Downloads folder
  2. We’re going to be installing the checker binaries into your /usr/local/bin directory. Run the following command to ensure that this directory exists:
  3.  
    sudo mkdir -p /usr/local/bin
  4. Open Terminal.app and move the contents of checker-NN to the /usr/local/bin directory (remember to replace NN with the build number of your download):
    sudo mv ~/Downloads/checker-NN/* /usr/local/bin/
Run
The analyzer must be run after a xcodebuild clean command.

xcodebuild clean
scan-build -k -V xcodebuild

No comments:

Post a Comment