diff options
Diffstat (limited to 'www/analyzer')
-rw-r--r-- | www/analyzer/content.css | 18 | ||||
-rw-r--r-- | www/analyzer/images/scan_build_cmd.png | bin | 0 -> 29669 bytes | |||
-rw-r--r-- | www/analyzer/index.html | 47 | ||||
-rw-r--r-- | www/analyzer/latest_checker.html.incl | 2 | ||||
-rw-r--r-- | www/analyzer/menu.html.incl | 3 | ||||
-rw-r--r-- | www/analyzer/scan-build.html | 160 | ||||
-rw-r--r-- | www/analyzer/xcode.html | 136 |
7 files changed, 319 insertions, 47 deletions
diff --git a/www/analyzer/content.css b/www/analyzer/content.css index 823fae265c954..b22cca9ff55e0 100644 --- a/www/analyzer/content.css +++ b/www/analyzer/content.css @@ -47,6 +47,21 @@ IMG.img_slide { /* Tables */ tr { vertical-align:top } +table.options thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:left; + border-top: 2px solid #cccccc; + border-bottom: 2px solid #cccccc; + font-weight: bold; font-family: Verdana +} +table.options { border: 1px #cccccc solid } +table.options { border-collapse: collapse; border-spacing: 0px } +table.options { margin-left:0px; margin-top:20px; margin-bottom:20px } +table.options td { border-bottom: 1px #cccccc dotted } +table.options td { padding:5px; padding-left:8px; padding-right:8px } +table.options td { text-align:left; font-size:9pt } + /* Collapsing Trees: http://dbtree.megalingo.com/web/demo/simple-collapsible-tree.cfm */ #collapsetree, #collapsetree a:link, #collapsetree li a:link, #collapsetree a:visited, #collapsetree li a:visited{color:#000;text-decoration:none} #collapsetree,#collapsetree ul{list-style-type:none; width:auto; margin:0; padding:0} @@ -60,4 +75,5 @@ tr { vertical-align:top } #collapsetree ul li.click a{background:url(images/tree/bullet.gif) center left no-repeat} #collapsetree li a.subMenu,#collapsetree ul li a.subMenu{background:url(images/tree/plus.gif) center left no-repeat} #collapsetree li a.click{background:url(images/tree/minus.gif) center left no-repeat} -#collapsetree ul li a.click{background:url(images/tree/minus.gif) center left no-repeat}
\ No newline at end of file +#collapsetree ul li a.click{background:url(images/tree/minus.gif) center left no-repeat} + diff --git a/www/analyzer/images/scan_build_cmd.png b/www/analyzer/images/scan_build_cmd.png Binary files differnew file mode 100644 index 0000000000000..464fd4e129a20 --- /dev/null +++ b/www/analyzer/images/scan_build_cmd.png diff --git a/www/analyzer/index.html b/www/analyzer/index.html index 006bc5c265220..335ca8b34aa12 100644 --- a/www/analyzer/index.html +++ b/www/analyzer/index.html @@ -19,15 +19,20 @@ <h1>Clang Static Analyzer</h1> -<p>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.</p> +<p>The Clang Static Analyzer is source code analysis tool that find bugs in C +and Objective-C programs.</p> -<p>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.</p> +<p>Currently it can be run either as a <a href="/scan-build.html">standalone +tool</a> or <a href="/xcode.html">within Xcode</a>. The standalone tool is +invoked from the command-line, and is intended to be run in tandem with a build +of a codebase.</p> -<p>Both are 100% open source and are part of the <a -href="http://clang.llvm.org">Clang</a> project.</p> +<p>The analyzer is 100% open source and are part of the <a +href="http://clang.llvm.org">Clang</a> project. Like the rest of Clang, the +analyzer is implemented as a C++ library that can be used by other tools and +applications.</p> + +<h2>Download</h2> <!-- Generated from: http://www.spiffycorners.com/index.php --> @@ -91,16 +96,35 @@ href="http://clang.llvm.org">Clang</a> project.</p> <b class="spiffy5"></b></b> <div class="spiffyfg"> <div style="padding:15px"> - <h2 style="padding:0px; margin:0px">Download</h2> - <h3 style="margin-top:5px">Mac OS X</h3> + <h3 style="margin:0px;padding:0px">Mac OS X</h3> <ul> - <li>Latest build (Universal binary, 10.5+): + <li>Latest build (Universal binary, 10.5+):<br> <!--#include virtual="latest_checker.html.incl"--> </li> + <li>Can be used both from the command line and within Xcode</li> <li><a href="/installation.html">Installation</a> and <a href="/scan-build.html">usage</a></li> </ul> - <h3>Other Platforms</h3> + </div> + </div> + <b class="spiffy"> + <b class="spiffy5"></b> + <b class="spiffy4"></b> + <b class="spiffy3"></b> + <b class="spiffy2"><b></b></b> + <b class="spiffy1"><b></b></b></b> +</div> + +<div style="padding:0; margin-top:10px; font-size: 90%"> + <b class="spiffy"> + <b class="spiffy1"><b></b></b> + <b class="spiffy2"><b></b></b> + <b class="spiffy3"></b> + <b class="spiffy4"></b> + <b class="spiffy5"></b></b> + <div class="spiffyfg"> + <div style="padding:15px"> + <h3 style="margin:0px;padding:0px">Other Platforms</h3> <p>For other platforms, please follow the instructions for <a href="/installation#OtherPlatforms">building the analyzer</a> from source code.<p> @@ -114,6 +138,7 @@ href="http://clang.llvm.org">Clang</a> project.</p> <b class="spiffy1"><b></b></b></b> </div> + </td><td style="padding-left:10px"> <a href="images/analyzer_xcode.png"><img src="images/analyzer_xcode.png" width="450x" border=0></a> <center><b>Viewing static analyzer results in Xcode 3.2</b></center> diff --git a/www/analyzer/latest_checker.html.incl b/www/analyzer/latest_checker.html.incl index 87ef5fd45ed0d..3368167b7fabb 100644 --- a/www/analyzer/latest_checker.html.incl +++ b/www/analyzer/latest_checker.html.incl @@ -1 +1 @@ -<b><a href="http://checker.minormatter.com/checker-234.tar.bz2">checker-234.tar.bz2</a></b> (built February 9, 2010) +<b><a href="http://checker.minormatter.com/checker-236.tar.bz2">checker-236.tar.bz2</a></b> (built February 25, 2010) diff --git a/www/analyzer/menu.html.incl b/www/analyzer/menu.html.incl index 8d465e44c2bdc..a06eb58b0e9ca 100644 --- a/www/analyzer/menu.html.incl +++ b/www/analyzer/menu.html.incl @@ -16,7 +16,8 @@ User Manual <ul> <li><a href="/installation.html">Obtaining the Analyzer</a></li> - <li><a href="/scan-build.html">Running the Analyzer</tt></a></li> + <li><a href="/scan-build.html">Command line usage</a></li> + <li><a href="/xcode.html">Using within Xcode</a></li> <li><a href="/available_checks.html">Available Checks</a></li> <li><a href="/annotations.html">Source-level Annotations</a></li> </ul> diff --git a/www/analyzer/scan-build.html b/www/analyzer/scan-build.html index 16bdbfdbe219c..1db15fec99eb3 100644 --- a/www/analyzer/scan-build.html +++ b/www/analyzer/scan-build.html @@ -2,10 +2,11 @@ "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> - <title>Running the Analyzer</title> + <title>scan-build: running the analyzer from the command line</title> <link type="text/css" rel="stylesheet" href="content.css" /> <link type="text/css" rel="stylesheet" href="menu.css" /> - <script type="text/javascript" src="scripts/menu.js"></script> + <script type="text/javascript" src="scripts/menu.js"></script> + <script type="text/javascript" src="scripts/dbtree.js"></script> </head> <body> @@ -13,48 +14,65 @@ <!--#include virtual="menu.html.incl"--> <div id="content"> -<style> -table.options thead { - background-color:#eee; color:#666666; - font-weight: bold; cursor: default; - text-align:left; - border-top: 2px solid #cccccc; - border-bottom: 2px solid #cccccc; - font-weight: bold; font-family: Verdana -} -table.options { border: 1px #cccccc solid } -table.options { border-collapse: collapse; border-spacing: 0px } -table.options { margin-left:0px; margin-top:20px; margin-bottom:20px } -table.options td { border-bottom: 1px #cccccc dotted } -table.options td { padding:5px; padding-left:8px; padding-right:8px } -table.options td { text-align:left; font-size:9pt } -</style> - -<h1>Running the Analyzer</h1> - -<p>While the static analyzer engine can be used as a library, many users will -likely use the command-line interface to the analyzer to analyze projects. This -page documents <tt>scan-build</tt>, a program that users can use from the -command line to analyze all the source files used to build a project.</p> - -<h3>Contents</h3> +<h1>scan-build: running the analyzer from the command line</h1> -<ul> -<li><a href="#scanbuild">scan-build</a></li> +<table style="margin-top:0px" width="100%" border="0" cellpadding="0px" cellspacing="0"> +<tr><td> + +<h3>What is it?</h3> +<p><b>scan-build</b> is a command line utility that enables a user to run the +static analyzer over their codebase as part of performing a regular build (from +the command line).</p> + +<h3>How does it work?</h3> +<p>During a project build, as source files are compiled they are also analyzed +in tandem by the static analyzer.</p> + +<p>Upon completion of the build, results are then presented to the user within a +web browser.</p> + +<h3>Will it work with any build system?</h3> +<p><b>scan-build</b> has little or no knowledge about how you build your code. +It works by overriding the <tt>CC</tt> and <tt>CXX</tt> 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 <tt>gcc</tt> to compile your code (assuming that <tt>gcc</tt> is your +compiler) and then executes the static analyzer to analyze your code.</p> + +<p>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 +the best use of <b>scan-build</b>, which includes getting it to work when the +aforementioned hack fails to work.</p> + +</td> +<td style="padding-left:10px"> +<center> + <img src="images/scan_build_cmd.png" width="450px" border=0><br> + <a href="images/analyzer_html.png"><img src="images/analyzer_html.png" width="450px" border=0></a> +<br><b>Viewing static analyzer results in a web browser</b></center> +</td></tr></table> + +<h2>Contents</h2> + +<ul id="collapsetree" class="dbtree onclick multiple"> +<li><a href="#scanbuild">Getting Started</a> <ul> <li><a href="#scanbuild_basicusage">Basic Usage</a></li> <li><a href="#scanbuild_otheroptions">Other Options</a></li> <li><a href="#scanbuild_output">Output of scan-build</a></li> </ul> -<li><a href="#recommendedguidelines">Recommended Usage Guidelines</a></li> +</li> +<li><a href="#recommendedguidelines">Recommended Usage Guidelines</a> <ul> <li><a href="#recommended_debug">Always Analyze a Project in its "Debug" Configuration</a></li> <li><a href="#recommended_verbose">Use Verbose Output when Debugging scan-build</a></li> <li><a href="#recommended_autoconf">Run './configure' through scan-build</a></li> </ul> +</li> +<li><a href="#iphone">Analyzing iPhone Projects</a></li> </ul> -<h2 id="scanbuild">scan-build</h2> +<h2 id="scanbuild">Getting Started</h2> <p>The <tt>scan-build</tt> command can be used to analyze an entire project by essentially interposing on a project's build process. This means that to run the @@ -165,14 +183,14 @@ completes, pass <b>-V</b> to <tt>scan-build</tt>. <p>This section describes a few recommendations with running the analyzer.</p> -<h3 id="recommended_debug">Always Analyze a Project in its "Debug" Configuration</h3> +<h3 id="recommended_debug">ALWAYS analyze a project in its "debug" configuration</h3> <p>Most projects can be built in a "debug" mode that enables assertions. Assertions are picked up by the static analyzer to prune infeasible paths, which in some cases can greatly reduce the number of false positives (bogus error reports) emitted by the tool.</p> -<h3 id="recommend_verbose">Use Verbose Output when Debugging scan-build</h3> +<h3 id="recommend_verbose">Use verbose output when debugging scan-build</h3> <p><tt>scan-build</tt> takes a <b>-v</b> option to emit verbose output about what it's doing; two <b>-v</b> options emit more information. Redirecting the @@ -245,6 +263,82 @@ the arguments over to <tt>gcc</tt>, but this may not work perfectly (please report bugs of this kind). --> +<h2 id="iphone">Analyzing iPhone Projects</h2> + +<p>Conceptually Xcode projects for iPhone applications are nearly the same as +their cousins for desktop applications. <b>scan-build</b> can analyze these +projects as well, but users often encounter problems with just building their +iPhone projects from the command line because there are a few extra preparative +steps they need to take (e.g., setup code signing).</p> + +<h3>Recommendation: use "Build and Analyze"</h3> + +<p>The absolute easiest way to analyze iPhone projects is to use the <a +href="http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html"><i>Build +and Analyze</i> feature in Xcode 3.2</a> (which is based on the Clang Static +Analyzer). There a user can analyze their project with the click of a button +without most of the setup described later.</p> + +<p><a href="/xcode.html">Instructions are available</a> on this +website on how to use open source builds of the analyzer as a replacement for +the one bundled with Xcode.</p> + +<h3>Using scan-build directly</h3> + +<p>If you wish to use <b>scan-build</b> with your iPhone project, keep the +following things in mind:</p> + +<ul> + <li>Analyze your project in the <tt>Debug</tt> configuration, either by setting +this as your configuration with Xcode or by passing <tt>-configuration +Debug</tt> to <tt>xcodebuild</tt>.</li> + <li>Analyze your project using the <tt>Simulator</tt> as your base SDK. It is +possible to analyze your code when targetting the device, but this is much +easier to do when using Xcode's <i>Build and Analyze</i> feature.</li> + <li>Check that your code signing SDK is set to the simulator SDK as well, and make sure this option is set to <tt>Don't Code Sign</tt>.</li> +</ul> + +<p>Note that you can most of this without actually modifying your project. For +example, if your application targets iPhoneOS 2.2, you could run +<b>scan-build</b> in the following manner from the command line:</p> + +<pre class="code_example"> +$ scan-build xcodebuild -configuration Debug -sdk iphonesimulator2.2 +</pre> + +Alternatively, if your application targets iPhoneOS 3.0: + +<pre class="code_example"> +$ scan-build xcodebuild -configuration Debug -sdk iphonesimulator3.0 +</pre> + +<h3>Gotcha: using the right compiler</h3> + +<p>Recall that <b>scan-build</b> analyzes your project by using <tt>gcc</tt> to +compile the project and <tt>clang</tt> to analyze your project. When analyzing +iPhone projects, <b>scan-build</b> may pick the wrong compiler than the one +Xcode would use to build your project. This is because multiple versions of +<tt>gcc</tt> may be installed on your system, especially if you are developing +for the iPhone.</p> + +<p>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 <b>scan-build</b> +finds the correct version of <tt>gcc</tt>. Otherwise, you may see strange build +errors that only happen when you run <tt>scan-build</tt>. + +<p><b>scan-build</b> provides the <tt>--use-cc</tt> and <tt>--use-c++</tt> +options to hardwire which compiler scan-build should use for building your code. +Note that although you are chiefly interested in analyzing your project, keep in +mind that running the analyzer is intimately tied to the build, and not being +able to compile your code means it won't get fully analyzed (if at all).</p> + +<p>If you aren't certain which compiler Xcode uses to build your project, try +just running <tt>xcodebuild</tt> (without <b>scan-build</b>). You should see the +full path to the compiler that Xcode is using, and use that as an argument to +<tt>--use-cc</tt>.</p> + </div> </div> </body> diff --git a/www/analyzer/xcode.html b/www/analyzer/xcode.html new file mode 100644 index 0000000000000..474156e574f9d --- /dev/null +++ b/www/analyzer/xcode.html @@ -0,0 +1,136 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <title>Build and Analyze: running the analyzer within Xcode</title> + <link type="text/css" rel="stylesheet" href="content.css" /> + <link type="text/css" rel="stylesheet" href="menu.css" /> + <script type="text/javascript" src="scripts/menu.js"></script> + <script type="text/javascript" src="scripts/dbtree.js"></script> +</head> +<body> + +<div id="page"> +<!--#include virtual="menu.html.incl"--> +<div id="content"> + +<h1>Build and Analyze: running the analyzer within Xcode</h1> + +<table style="margin-top:0px" width="100%" border="0" cellpadding="0px" cellspacing="0"> +<tr><td> + +<h3>What is it?</h3> +<p><i>Build and Analyze</i> is an Xcode feature (introduced in Xcode 3.2) that +allows users to run the Clang Static Analyzer <a +href="http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html">directly +within Xcode</a>.</p> + +<p>It integrates directly with the Xcode build system and +presents analysis results directly within Xcode's editor.</p> + +<h3>Can I use the open source analyzer builds with Xcode?</h3> + +<p><b>Yes</b>. Instructions are included below.</p> + +</td> +<td style="padding-left:10px"> +<center> + <a href="images/analyzer_xcode.png"><img src="images/analyzer_xcode.png" width="620px" border=0></a> +<br><b>Viewing static analyzer results in Xcode</b></center> +</td></tr></table> + +<h3>Key features:</h3> +<ul> + <li><b>Integrated workflow:</b> Results are integrated within Xcode. There is + no experience of using a separate tool, and activating the analyzer requires a + single keystroke or mouse click.</li> + <li><b>Transparency:</b> Works effortlessly with Xcode projects (including iPhone projects). + <li><b>Cons:</b> Doesn't work well with non-Xcode projects. For those, + consider using <a href="/scan-build.html"><b>scan-build</b></a>. +</ul> + + +<h2>Getting Started</h2> + +<p>Xcode 3.2 is available as a free download from Apple, with <a +href="http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html">instructions available</a> +for using <i>Build and Analyze</i>.</p> + +<h2>Using open source analyzer builds with <i>Build and Analyze</i></h2> + +<p>By default, Xcode uses the version of <tt>clang</tt> that came bundled with +it to provide the results for <i>Build and Analyze</i>. It is possible to change +Xcode's behavior to use an alternate version of <tt>clang</tt> for this purpose +while continuing to use the <tt>clang</tt> that came with Xcode for compiling +projects.</p> + +<h3>Why try open source builds?</h3> + +<p>The advantage of using open source analyzer builds (provided on this website) +is that they are often newer than the analyzer provided with Xcode, and thus can +contain bug fixes, new checks, or simply better analysis.</p> + +<p>On the other hand, new checks can be experimental, with results of variable +quality. Users are encouraged to <a href="filing_bugs.html">file bug reports</a> +(for any version of the analyzer) where they encounter false positives or other +issues.</p> + +<h3>set-xcode-analyzer</h3> + +<p>Starting with analyzer build checker-234, analyzer builds contain a command +line utility called <tt>set-xcode-analyzer</tt> that allows users to change what +copy of <tt>clang</tt> that Xcode uses for <i>Build and Analyze</i>:</p> + +<pre class="code_example"> +$ <b>set-xcode-analyzer -h</b> +Usage: set-xcode-analyzer [options] + +Options: + -h, --help show this help message and exit + --use-checker-build=PATH + Use the Clang located at the provided absolute path, + e.g. /Users/foo/checker-1 + --use-xcode-clang Use the Clang bundled with Xcode +</pre> + +<p>Operationally, <b>set-xcode-analyzer</b> edits Xcode's configuration files +(in <tt>/Developer</tt>) to point it to use the version of <tt>clang</tt> you +specify for static analysis. Within this model it provides you two basic modes:</p> + +<ul> + <li><b>--use-xcode-clang</b>: Switch Xcode (back) to using the <tt>clang</tt> that came bundled with it for static analysis.</li> + <li><b>--use-checker-build</b>: Switch Xcode to using the <tt>clang</tt> provided by the specified analyzer build.</li> +</ul> + +<h4>Examples</h4> + +<p><b>Example 1</b>: Telling Xcode to use checker-235 for <i>Build and Analyze</i>:</p> + +<pre class="code_example"> +$ pwd +/tmp +$ tar xjf checker-235.tar.bz2 +$ checker-235/set-xcode-analyzer --use-checker-build=/tmp/checker-235 +</pre> + +<p>Note that you typically won't install an analyzer build in <tt>/tmp</tt>, but +the point of this example is that <tt>set-xcode-analyzer</tt> just wants a full +path to an untarred analyzer build.</p> + +<p><b>Example 2</b>: Telling Xcode to use a very specific version of <tt>clang</tt>:</p> + +<pre class="code_example"> +$ set-xcode-analyzer --use-checker-build=~/mycrazyclangbuild/bin/clang +</pre> + +<p><b>Example 3</b>: Resetting Xcode to its default behavior:</p> + +<pre class="code_example"> +$ set-xcode-analyzer --use-xcode-clang +</pre> + +</div> +</div> +</body> +</html> + |