blob: 3c784a9b4e2a4aebf8893d38ecce66c844d4a0bf [file] [log] [blame]
Ted Kremenek591b9072009-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>
6 <link type="text/css" rel="stylesheet" href="menu.css" />
7 <link type="text/css" rel="stylesheet" href="content.css" />
8</head>
9<body>
10
11<!--#include virtual="menu.html.incl"-->
12
13<div id="content">
14
15<h1>Clang Static Analyzer</h1>
16
17<p>The Clang Static Analyzer consists of both a source code analysis framework
18and a standalone tool that finds bugs in C and Objective-C programs. The
19standalone tool is invoked from the command-line, and is intended to run in
20tandem with a build of a project or code base.</p>
21
22<p>Both are 100% open source and are part of the <a
23href="http://clang.llvm.org">Clang</a> project.</p>
24
Ted Kremenek51667ee2010-02-08 22:12:48 +000025<center>
26<table border=0 cellspacing=20>
27 <tr>
28 <td><center><img src="/images/analyzer_html.png"></center></td>
29 <td><center><img src="/images/analyzer_xcode.png"></center></td>
30 </tr>
31 <tr>
32 <td><center>Viewing results in a web browser</center></td>
33 <td><center>Viewing results in Xcode 3.2</center></td>
34 </tr>
35</table>
36</center>
37
Ted Kremenek591b9072009-06-08 21:21:24 +000038<!-- Generated from: http://www.spiffycorners.com/index.php -->
39
40<style type="text/css">
41.spiffy{display:block}
42.spiffy *{
43 display:block;
44 height:1px;
45 overflow:hidden;
46 font-size:.01em;
47 background:#EBF0FA}
48.spiffy1{
49 margin-left:3px;
50 margin-right:3px;
51 padding-left:1px;
52 padding-right:1px;
53 border-left:1px solid #f6f8fc;
54 border-right:1px solid #f6f8fc;
55 background:#f0f3fb}
56.spiffy2{
57 margin-left:1px;
58 margin-right:1px;
59 padding-right:1px;
60 padding-left:1px;
61 border-left:1px solid #fdfdfe;
62 border-right:1px solid #fdfdfe;
63 background:#eef2fa}
64.spiffy3{
65 margin-left:1px;
66 margin-right:1px;
67 border-left:1px solid #eef2fa;
68 border-right:1px solid #eef2fa;}
69.spiffy4{
70 border-left:1px solid #f6f8fc;
71 border-right:1px solid #f6f8fc}
72.spiffy5{
73 border-left:1px solid #f0f3fb;
74 border-right:1px solid #f0f3fb}
75.spiffyfg{
76 background:#EBF0FA}
77
78.spiffyfg h2 {
79 margin:0px; padding:10px;
80}
81</style>
82
83<style type="text/css">
84 #left { float:left; }
85 #left h2 { margin:1px; padding-top:0px; }
86 #right { float:left; margin-left:20px; margin-right:20px; padding:0px ;}
87 #right h2 { padding:0px; margin:0px; }
88 #wrappedcontent { padding:15px;}
89</style>
90
91<div style="padding:0px">
92 <b class="spiffy">
93 <b class="spiffy1"><b></b></b>
94 <b class="spiffy2"><b></b></b>
95 <b class="spiffy3"></b>
96 <b class="spiffy4"></b>
97 <b class="spiffy5"></b></b>
98 <div class="spiffyfg">
99 <div style="padding:15px">
100 <h2 style="padding:0px; margin:0px">Download</h2>
101 <h3 style="margin-top:5px">Mac OS X</h3>
102 <ul>
103 <li>Latest build (Universal binary, 10.5+):
104 <!--#include virtual="latest_checker.html.incl"-->
105 </li>
106 <li><a href="/installation.html">Installation</a> and <a
107 href="/scan-build.html">usage</a></li>
108 </ul>
109 <h3>Other Platforms</h3>
110 <p>For other platforms, please follow the instructions for <a
111 href="/installation#OtherPlatforms">building the analyzer</a> from
112 source code.<p>
113 </div>
114 </div>
115 <b class="spiffy">
116 <b class="spiffy5"></b>
117 <b class="spiffy4"></b>
118 <b class="spiffy3"></b>
119 <b class="spiffy2"><b></b></b>
120 <b class="spiffy1"><b></b></b></b>
121</div>
122
123<h2 id="StaticAnalysis">What is Static Analysis?</h2>
124
125<p>The term &quot;static analysis&quot; is conflated, but here we use it to mean
126a collection of algorithms and techniques used to analyze source code in order
127to automatically find bugs. The idea is similar in spirit to compiler warnings
128(which can be useful for finding coding errors) but to take that idea a step
129further and find bugs that are traditionally found using run-time debugging
130techniques such as testing.</p>
131
132<p>Static analysis bug-finding tools have evolved over the last several decades
133from basic syntactic checkers to those that find deep bugs by reasoning about
134the semantics of code. The goal of the Clang Static Analyzer is to provide a
135industrial-quality static analysis framework for analyzing C and Objective-C
136programs that is freely available, extensible, and has a high quality of
137implementation.</p>
138
139<h3 id="Clang">Part of Clang and LLVM</h3>
140
141<p>As its name implies, the Clang Static Analyzer is built on top of <a
142href="http://clang.llvm.org">Clang</a> and <a href="http://llvm.org">LLVM</a>.
143Strictly speaking, the analyzer is part of Clang, as Clang consists of a set of
144reusable C++ libraries for building powerful source-level tools. The static
145analysis engine used by the Clang Static Analyzer is a Clang library, and has
146the capability to be reused in different contexts and by different clients.</p>
147
148<h2>Important Points to Consider</h2>
149
150<p>While we believe that the static analyzer is already very useful for finding
151bugs, we ask you to bear in mind a few points when using it.</p>
152
153<h3>Work-in-Progress</h3>
154
155<p>The analyzer is a continuous work-in-progress.
156There are many planned enhancements to improve both the precision and scope of
157its analysis algorithms as well as the kinds bugs it will find. While there are
158fundamental limitations to what static analysis can do, we have a long way to go
159before hitting that wall.</p>
160
161<h3>Slower than Compilation</h3>
162
163<p>Operationally, using static analysis to
164automatically find deep program bugs is about trading CPU time for the hardening
165of code. Because of the deep analysis performed by state-of-the-art static
166analysis tools, static analysis can be much slower than compilation.</p>
167
168<p>While the Clang Static Analyzer is being designed to be as fast and
169light-weight as possible, please do not expect it to be as fast as compiling a
170program (even with optimizations enabled). Some of the algorithms needed to find
171bugs require in the worst case exponential time.</p>
172
173<p>The Clang Static Analyzer runs in a reasonable amount of time by both
174bounding the amount of checking work it will do as well as using clever
175algorithms to reduce the amount of work it must do to find bugs.</p></li>
176
177<h3>False Positives</h3>
178
179<p>Static analysis is not perfect. It can falsely flag bugs in a program where
180the code behaves correctly. Because some code checks require more analysis
181precision than others, the frequency of false positives can vary widely between
182different checks. Our long-term goal is to have the analyzer have a low false
183positive rate for most code on all checks.</p>
184
185<p>Please help us in this endeavor by <a href="filing_bugs.html">reporting false
186positives</a>. False positives cannot be addressed unless we know about
187them.</p>
188
189<h3>More Checks</h3>
190
Zhongxing Xu0c3a16d2009-06-15 13:22:32 +0000191<p>Static analysis is not magic; a static analyzer can only find bugs that it
192has been specifically engineered to find. If there are specific kinds of bugs
193you would like the Clang Static Analyzer to find, please feel free to
194file <a href="filing_bugs.html">feature requests</a> or contribute your own
195patches.</p>
Ted Kremenek591b9072009-06-08 21:21:24 +0000196
197</div>
198</body>
199</html>
200