From: Anna Zaks
scan-build has little or no knowledge about how you build your code. It works by overriding the CC and CXX environment variables to (hopefully) change your build to use a "fake" compiler instead of the -one that would normally build your project. By default, this fake compiler -executes gcc to compile your code (assuming that gcc is your -compiler) and then executes the static analyzer to analyze your code.
+one that would normally build your project. This fake compiler executes either +clang or gcc (depending on the platform) to compile your +code and then executes the static analyzer to analyze your code.This "poor man's interposition" works amazingly well in many cases and falls down in others. Please consult the information on this page on making @@ -77,8 +77,8 @@ aforementioned hack fails to work.
The scan-build command can be used to analyze an entire project by essentially interposing on a project's build process. This means that to run the analyzer using scan-build, you will use scan-build to analyze -the source files compiled by gcc during a project build. This means -that any files that are not compiled will also not be analyzed.
+the source files compiled by gcc/clang during a project build. +This means that any files that are not compiled will also not be analyzed.Running configure typically generates makefiles that have hardwired @@ -314,18 +314,17 @@ $ scan-build xcodebuild -configuration Debug -sdk iphonesimulator3.0
Recall that scan-build analyzes your project by using gcc to -compile the project and clang to analyze your project. When analyzing +
Recall that scan-build analyzes your project by using a compiler to +compile the project and clang to analyze your project. The script uses +simple heuristics to determine which compiler should be used (it defaults to +clang on Darwin and gcc on other platforms). When analyzing iPhone projects, scan-build may pick the wrong compiler than the one -Xcode would use to build your project. This is because multiple versions of -gcc may be installed on your system, especially if you are developing -for the iPhone.
- -Where this particularly might be a problem is if you are using Mac OS 10.5 -(Leopard) to develop for iPhone OS 3.0. The default desktop compiler on Leopard -is gcc-4.0, while the compiler for iPhone OS 3.0 is gcc-4.2. When compiling your -application to run on the simulator, it is important that scan-build -finds the correct version of gcc. Otherwise, you may see strange build +Xcode would use to build your project. For example, this could be because +multiple versions of a compiler may be installed on your system, especially if +you are developing for the iPhone.
+ +When compiling your application to run on the simulator, it is important that scan-build +finds the correct version of gcc/clang. Otherwise, you may see strange build errors that only happen when you run scan-build.
scan-build provides the --use-cc and --use-c++