Setting Up Clang Static Analyzer and Xcode (in three steps)

Shaun, Dec 2

Xcode's Build & Analyze is great, but as far as I've encountered, it doesn't find everything that Clang Static Analyzer does, even if it is based on it.

Here's a quick guide to install Clang:

  1. Download the latest "checker-XX.tar.bz2" from http://clang-analyzer.llvm.org/
  2. Extract, and move the contents to "/Developer/Tools/clang/"
  3. Add this line to your ~/.bash_profile file.
    alias clang_gen='rm -rf /tmp/scan-build*; xcodebuild clean; /Developer/Tools/clang/scan-build --view xcodebuild'

That's pretty much it!  Just go to your project directory in Terminal now, and run "clang_gen".  Once it's done running, it should open up Safari with the results.

blog comments powered by Disqus