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