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