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