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