简体   繁体   中英

problem in configuring clang static analzer

i follow the following steps to install and configure clang static analyser.but still i could not run scan-build command in project directory can anyone can give correct tutorial to set path and also run scan-build command.terminal shows "scan-build command not found" the steps i followed:

Installation: Navigate to http://clang.llvm.org/StaticAnalysis.html Download the linked checker tarbell (it says tar.bz2, but it's really tar.bz2.tar). Extract that and copy that to a directory on your device. I chose ~/Developer/clang Open terminal and type sudo nano /etc/paths Enter the directory in which you keep your clang stuffs. Press 'Ctrl + X' to Exit, and press 'Y' to save.

You're now done with installation. Quit and restart terminal.

To use this, First make sure you go into Xcode and "Clean All" before you do anything. When that's all set, open terminal and navigate to the directory of the app you want to build. Enter the following command. Make sure to replace the name od the sdk with the one you currently want to build with. scan-build -k -V xcodebuild -configuration Debug -sdk iphonesimulator3.0

I've never added paths that way. But regardless you should not need to.

If you added clang to ~/Developer/clang, then just change the command you are using to run it to:

~/Developer/clang/scan-build -k -V xcodebuild -configuration Debug -sdk iphonesimulator3.0

Ran into this problem myself. It seems that scan-build is actually a perl script which changes some env variables so that clang compiler gets run before the work is passed to the real project compiler. This way clang can perform static analysis.

Try running like this:

perl <CLANG_PATH>/llvm/tools/clang/tools/scan-build/scan-build -k -o $HOME/clang-result make

Before that make sure you have the clang executable in the PATH variable:

echo $PATH

To add it:

export PATH=$PATH:<CLANG_BUILD_BIN_PATH>

eg: export PATH=$PATH:$HOME/clang/build/Release+Asserts/bin/

Try AnalysisTool, it's gui wrapper around LLVM/Clang static analyzer. It works great. http://www.karppinen.fi/analysistool/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM