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