From: Anna Zaks Date: Fri, 6 Jan 2012 01:54:08 +0000 (+0000) Subject: [analyzer] Update the docs to reflect that gcc is not the only default X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a772b86a6edaf9f110bf7d3e6c8201723371bc9a;p=clang [analyzer] Update the docs to reflect that gcc is not the only default compiler option. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147645 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build index dae86f4b5e..8b79c84ae5 100755 --- a/tools/scan-build/scan-build +++ b/tools/scan-build/scan-build @@ -967,11 +967,11 @@ OPTIONS: exit status of $Prog to be 1 if it found potential bugs and 0 otherwise. - --use-cc [compiler path] - By default, $Prog uses 'gcc' to compile and link + --use-cc [compiler path] - $Prog attempts to guess the default compiler for --use-cc=[compiler path] your C and Objective-C code. Use this option to specify an alternate compiler. - --use-c++ [compiler path] - By default, $Prog uses 'g++' to compile and link + --use-c++ [compiler path] - $Prog attempts to guess the default compiler for --use-c++=[compiler path] your C++ and Objective-C++ code. Use this option to specify an alternate compiler. diff --git a/www/analyzer/scan-build.html b/www/analyzer/scan-build.html index 6c2833e799..e257407d86 100644 --- a/www/analyzer/scan-build.html +++ b/www/analyzer/scan-build.html @@ -35,9 +35,9 @@ web browser.

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.

Basic Usage

@@ -217,7 +217,7 @@ $ scan-build make interposing on the compiler. This interposition is currently done by scan-build temporarily setting the environment variable CC to ccc-analyzer. The program ccc-analyzer acts like a fake -compiler, forwarding its command line arguments over to gcc to perform +compiler, forwarding its command line arguments over to the compiler to perform regular compilation and clang to perform static analysis.

Running configure typically generates makefiles that have hardwired @@ -314,18 +314,17 @@ $ scan-build xcodebuild -configuration Debug -sdk iphonesimulator3.0

Gotcha: using the right compiler

-

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++