blob: 7d99ac9621e48650f8b5b928bfc7902298442b05 [file] [log] [blame]
Ted Kremenekf9f689b2009-06-08 21:21:24 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
5 <title>Clang Static Analyzer</title>
Ted Kremenekc319f5c2010-02-09 21:48:04 +00006 <link type="text/css" rel="stylesheet" href="content.css" />
7 <link type="text/css" rel="stylesheet" href="menu.css" />
Ted Kremenek8f8dcba2010-02-12 21:05:44 +00008 <script type="text/javascript" src="scripts/menu.js"></script>
Ted Kremenekf9f689b2009-06-08 21:21:24 +00009</head>
10<body>
11
Ted Kremenekc6ee3762010-02-09 23:05:59 +000012<div id="page">
Ted Kremenekf9f689b2009-06-08 21:21:24 +000013<!--#include virtual="menu.html.incl"-->
Ted Kremenekf9f689b2009-06-08 21:21:24 +000014<div id="content">
Ted Kremenekc6ee3762010-02-09 23:05:59 +000015
Ted Kremenekc6ee3762010-02-09 23:05:59 +000016
17<table style="margin-top:0px" width="100%" border="0" cellpadding="0px" cellspacing="0">
18<tr><td>
Ted Kremenek096807e2010-02-09 23:42:00 +000019
20<h1>Clang Static Analyzer</h1>
21
Ted Kremeneka3e1e992010-02-19 17:33:38 +000022<p>The Clang Static Analyzer is source code analysis tool that find bugs in C
23and Objective-C programs.</p>
Ted Kremenekc6ee3762010-02-09 23:05:59 +000024
Ted Kremeneka3e1e992010-02-19 17:33:38 +000025<p>Currently it can be run either as a <a href="/scan-build.html">standalone
26tool</a> or <a href="/xcode.html">within Xcode</a>. The standalone tool is
27invoked from the command-line, and is intended to be run in tandem with a build
28of a codebase.</p>
Ted Kremenekf9f689b2009-06-08 21:21:24 +000029
Ted Kremenekc52ea212010-03-12 16:46:36 +000030<p>The analyzer is 100% open source and is part of the <a
Ted Kremeneka3e1e992010-02-19 17:33:38 +000031href="http://clang.llvm.org">Clang</a> project. Like the rest of Clang, the
32analyzer is implemented as a C++ library that can be used by other tools and
33applications.</p>
34
35<h2>Download</h2>
Ted Kremenek9f25dd582010-02-08 22:12:48 +000036
Ted Kremenekf9f689b2009-06-08 21:21:24 +000037<!-- Generated from: http://www.spiffycorners.com/index.php -->
38
39<style type="text/css">
40.spiffy{display:block}
41.spiffy *{
42 display:block;
43 height:1px;
44 overflow:hidden;
45 font-size:.01em;
46 background:#EBF0FA}
47.spiffy1{
48 margin-left:3px;
49 margin-right:3px;
50 padding-left:1px;
51 padding-right:1px;
52 border-left:1px solid #f6f8fc;
53 border-right:1px solid #f6f8fc;
54 background:#f0f3fb}
55.spiffy2{
56 margin-left:1px;
57 margin-right:1px;
58 padding-right:1px;
59 padding-left:1px;
60 border-left:1px solid #fdfdfe;
61 border-right:1px solid #fdfdfe;
62 background:#eef2fa}
63.spiffy3{
64 margin-left:1px;
65 margin-right:1px;
66 border-left:1px solid #eef2fa;
67 border-right:1px solid #eef2fa;}
68.spiffy4{
69 border-left:1px solid #f6f8fc;
70 border-right:1px solid #f6f8fc}
71.spiffy5{
72 border-left:1px solid #f0f3fb;
73 border-right:1px solid #f0f3fb}
74.spiffyfg{
75 background:#EBF0FA}
76
77.spiffyfg h2 {
78 margin:0px; padding:10px;
79}
80</style>
81
82<style type="text/css">
83 #left { float:left; }
84 #left h2 { margin:1px; padding-top:0px; }
85 #right { float:left; margin-left:20px; margin-right:20px; padding:0px ;}
86 #right h2 { padding:0px; margin:0px; }
87 #wrappedcontent { padding:15px;}
88</style>
89
Ted Kremenekc6ee3762010-02-09 23:05:59 +000090<div style="padding:0px; font-size: 90%">
Ted Kremenekf9f689b2009-06-08 21:21:24 +000091 <b class="spiffy">
92 <b class="spiffy1"><b></b></b>
93 <b class="spiffy2"><b></b></b>
94 <b class="spiffy3"></b>
95 <b class="spiffy4"></b>
96 <b class="spiffy5"></b></b>
97 <div class="spiffyfg">
98 <div style="padding:15px">
Ted Kremeneka3e1e992010-02-19 17:33:38 +000099 <h3 style="margin:0px;padding:0px">Mac OS X</h3>
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000100 <ul>
Ted Kremenekba6ead42011-02-12 03:20:34 +0000101 <li>Latest build (Intel-only binary, 10.5+):<br>
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000102 <!--#include virtual="latest_checker.html.incl"-->
103 </li>
Ted Kremenek8688e072011-01-27 19:42:34 +0000104 <li><a href="/release_notes.html">Release notes</a></li></li>
Ted Kremenekcfc9dc62011-01-27 19:41:08 +0000105 <li>This build can be used both from the command line and from within Xcode</li>
106 <li><a href="/installation.html">Installation</a> and <a href="/scan-build.html">usage</a></li>
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000107 </ul>
Ted Kremeneka3e1e992010-02-19 17:33:38 +0000108 </div>
109 </div>
110 <b class="spiffy">
111 <b class="spiffy5"></b>
112 <b class="spiffy4"></b>
113 <b class="spiffy3"></b>
114 <b class="spiffy2"><b></b></b>
115 <b class="spiffy1"><b></b></b></b>
116</div>
117
118<div style="padding:0; margin-top:10px; font-size: 90%">
119 <b class="spiffy">
120 <b class="spiffy1"><b></b></b>
121 <b class="spiffy2"><b></b></b>
122 <b class="spiffy3"></b>
123 <b class="spiffy4"></b>
124 <b class="spiffy5"></b></b>
125 <div class="spiffyfg">
126 <div style="padding:15px">
127 <h3 style="margin:0px;padding:0px">Other Platforms</h3>
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000128 <p>For other platforms, please follow the instructions for <a
129 href="/installation#OtherPlatforms">building the analyzer</a> from
130 source code.<p>
131 </div>
132 </div>
133 <b class="spiffy">
134 <b class="spiffy5"></b>
135 <b class="spiffy4"></b>
136 <b class="spiffy3"></b>
137 <b class="spiffy2"><b></b></b>
138 <b class="spiffy1"><b></b></b></b>
139</div>
140
Ted Kremeneka3e1e992010-02-19 17:33:38 +0000141
Ted Kremenekc6ee3762010-02-09 23:05:59 +0000142</td><td style="padding-left:10px">
Ted Kremenek00d1c592010-02-10 06:43:43 +0000143<a href="images/analyzer_xcode.png"><img src="images/analyzer_xcode.png" width="450x" border=0></a>
Ted Kremenekc6ee3762010-02-09 23:05:59 +0000144<center><b>Viewing static analyzer results in Xcode 3.2</b></center>
Ted Kremenek00d1c592010-02-10 06:43:43 +0000145<a href="images/analyzer_html.png"><img src="images/analyzer_html.png" width="450px" border=0></a>
Ted Kremenekc6ee3762010-02-09 23:05:59 +0000146<center><b>Viewing static analyzer results in a web browser</b></center>
147</td></tr></table>
148
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000149<h2 id="StaticAnalysis">What is Static Analysis?</h2>
150
151<p>The term &quot;static analysis&quot; is conflated, but here we use it to mean
152a collection of algorithms and techniques used to analyze source code in order
153to automatically find bugs. The idea is similar in spirit to compiler warnings
154(which can be useful for finding coding errors) but to take that idea a step
155further and find bugs that are traditionally found using run-time debugging
156techniques such as testing.</p>
157
158<p>Static analysis bug-finding tools have evolved over the last several decades
159from basic syntactic checkers to those that find deep bugs by reasoning about
160the semantics of code. The goal of the Clang Static Analyzer is to provide a
161industrial-quality static analysis framework for analyzing C and Objective-C
162programs that is freely available, extensible, and has a high quality of
163implementation.</p>
164
165<h3 id="Clang">Part of Clang and LLVM</h3>
166
167<p>As its name implies, the Clang Static Analyzer is built on top of <a
168href="http://clang.llvm.org">Clang</a> and <a href="http://llvm.org">LLVM</a>.
169Strictly speaking, the analyzer is part of Clang, as Clang consists of a set of
170reusable C++ libraries for building powerful source-level tools. The static
171analysis engine used by the Clang Static Analyzer is a Clang library, and has
172the capability to be reused in different contexts and by different clients.</p>
173
174<h2>Important Points to Consider</h2>
175
176<p>While we believe that the static analyzer is already very useful for finding
177bugs, we ask you to bear in mind a few points when using it.</p>
178
179<h3>Work-in-Progress</h3>
180
181<p>The analyzer is a continuous work-in-progress.
182There are many planned enhancements to improve both the precision and scope of
183its analysis algorithms as well as the kinds bugs it will find. While there are
184fundamental limitations to what static analysis can do, we have a long way to go
185before hitting that wall.</p>
186
187<h3>Slower than Compilation</h3>
188
189<p>Operationally, using static analysis to
190automatically find deep program bugs is about trading CPU time for the hardening
191of code. Because of the deep analysis performed by state-of-the-art static
192analysis tools, static analysis can be much slower than compilation.</p>
193
194<p>While the Clang Static Analyzer is being designed to be as fast and
195light-weight as possible, please do not expect it to be as fast as compiling a
196program (even with optimizations enabled). Some of the algorithms needed to find
197bugs require in the worst case exponential time.</p>
198
199<p>The Clang Static Analyzer runs in a reasonable amount of time by both
200bounding the amount of checking work it will do as well as using clever
201algorithms to reduce the amount of work it must do to find bugs.</p></li>
202
203<h3>False Positives</h3>
204
205<p>Static analysis is not perfect. It can falsely flag bugs in a program where
206the code behaves correctly. Because some code checks require more analysis
207precision than others, the frequency of false positives can vary widely between
208different checks. Our long-term goal is to have the analyzer have a low false
209positive rate for most code on all checks.</p>
210
211<p>Please help us in this endeavor by <a href="filing_bugs.html">reporting false
212positives</a>. False positives cannot be addressed unless we know about
213them.</p>
214
215<h3>More Checks</h3>
216
Zhongxing Xua2937bc2009-06-15 13:22:32 +0000217<p>Static analysis is not magic; a static analyzer can only find bugs that it
218has been specifically engineered to find. If there are specific kinds of bugs
219you would like the Clang Static Analyzer to find, please feel free to
220file <a href="filing_bugs.html">feature requests</a> or contribute your own
221patches.</p>
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000222
223</div>
Ted Kremenekc6ee3762010-02-09 23:05:59 +0000224</div>
Ted Kremenekf9f689b2009-06-08 21:21:24 +0000225</body>
226</html>
227