Ted Kremenek | 33ee159 | 2012-05-10 19:10:47 +0000 | [diff] [blame] | 1 | .Dd May 3, 2012 |
| 2 | .Os [clang] [3.1] |
| 3 | .Dt SCAN-BUILD 1 |
| 4 | .Sh NAME |
| 5 | .Nm scan-build |
| 6 | .Nd Clang static analyzer |
| 7 | .Sh SYNOPSIS |
| 8 | .Nm |
| 9 | .Op Fl ohkvV |
| 10 | .Op Fl analyze-headers |
| 11 | .Op Fl enable-checker Op Ar checker_name |
| 12 | .Op Fl disable-checker Op Ar checker_name |
| 13 | .Op Fl -help |
| 14 | .Op Fl -html-title Op Ar =title |
| 15 | .Op Fl -keep-going |
| 16 | .Op Fl -plist |
| 17 | .Op Fl -plist-html |
| 18 | .Op Fl -status-bugs |
| 19 | .Op Fl -use-c++ Op Ar =compiler_path |
| 20 | .Op Fl -use-cc Op Ar =compiler_path |
| 21 | .Op Fl -view |
| 22 | .Op Fl constraints Op Ar model |
| 23 | .Op Fl maxloop Ar N |
| 24 | .Op Fl no-failure-reports |
| 25 | .Op Fl stats |
| 26 | .Op Fl store Op Ar model |
| 27 | .Ar build_command |
| 28 | .Op build_options |
| 29 | .\" |
| 30 | .\" Sh DESCRIPTION |
| 31 | .Sh OPTIONS |
| 32 | .Bl -tag -width indent |
| 33 | .It Fl analyze-headers |
| 34 | Also analyze functions in #included files. |
| 35 | .It Fl enable-checker Op Ar checker_name |
| 36 | .It Fl disable-checker Op Ar checker_name |
| 37 | Enable/disable |
| 38 | .Ar checker_name . |
| 39 | See |
| 40 | .Sx CONTROLLING CHECKERS |
| 41 | below. |
| 42 | .It Fl h |
| 43 | .It Fl -help |
| 44 | Display this message |
| 45 | .It Fl -html-title Ns Op = Ns Ar title |
| 46 | Specify the title used on generated HTML pages. |
| 47 | If |
| 48 | .Ar title |
| 49 | is not specified, a default title is used. |
| 50 | .It Fl k |
| 51 | .It Fl -keep-going |
| 52 | Add a |
| 53 | .Dq keep on going |
| 54 | option to the specified build command. Currently supports |
| 55 | make and xcodebuild. This is a convenience option; one can specify |
| 56 | this behavior directly using build options. |
| 57 | .It Fl o |
| 58 | Target directory for HTML report files. Subdirectories will be |
| 59 | created as needed to represent separate |
| 60 | .Dq runs |
| 61 | of the analyzer. If this option is not specified, a directory is |
| 62 | created in /tmp (TMPDIR on Mac OS X) to store the reports. |
| 63 | .It Fl -plist |
| 64 | Output the results as a set of |
| 65 | .Li |
| 66 | \.plist |
| 67 | files. (By default the output of |
| 68 | .Nm |
| 69 | is a set of HTML files.) |
| 70 | .It Fl -plist-html |
| 71 | Output the results as a set of HTML and .plist files |
| 72 | .It Fl -status-bugs |
| 73 | Set exit status to 1 if it found potential bugs and 0 otherwise. By |
| 74 | default the exit status of |
| 75 | .Nm |
| 76 | is the same as the executed build command. |
| 77 | .It Fl -use-c++ Ns Op = Ns Ar compiler_path |
| 78 | Guess the default compiler for your C++ and Objective-C++ code. Use this |
| 79 | option to specify an alternate compiler. |
| 80 | .It Fl -use-cc Ns Op = Ns Ar compiler_path |
| 81 | Guess the default compiler for your C and Objective-C code. Use this |
| 82 | option to specify an alternate compiler. |
| 83 | .It Fl v |
| 84 | Verbose output from |
| 85 | .Nm |
| 86 | and the analyzer. A second and |
| 87 | third |
| 88 | .Ar v |
| 89 | increases verbosity. |
| 90 | .It Fl V |
| 91 | .It Fl -view |
| 92 | View analysis results in a web browser when the build completes. |
| 93 | .It Fl constraints Op Ar model |
| 94 | Specify the contraint engine used by the analyzer. By default the |
| 95 | .Ql range |
| 96 | model is used. Specifying |
| 97 | .Ql basic |
| 98 | uses a simpler, less powerful constraint model used by checker-0.160 |
| 99 | and earlier. |
| 100 | .It Fl maxloop Ar N |
| 101 | Specifiy the number of times a block can be visited before giving |
| 102 | up. Default is 4. Increase for more comprehensive coverage at a |
| 103 | cost of speed. |
| 104 | .It Fl no-failure-reports |
| 105 | Do not create a |
| 106 | .Ql failures |
| 107 | subdirectory that includes analyzer crash reports and preprocessed |
| 108 | source files. |
| 109 | .It Fl stats |
| 110 | Generates visitation statistics for the project being analyzed. |
| 111 | .It Fl store Op Ar model |
| 112 | Specify the store model used by the analyzer. By default, the |
| 113 | .Ql region |
| 114 | store model is used. |
| 115 | .Ql region |
| 116 | specifies a field- |
| 117 | sensitive store model. Users can also specify |
| 118 | .Ql basic |
| 119 | which is far less precise but can more quickly analyze code. |
| 120 | .Ql basic |
| 121 | was the default store model for checker-0.221 and earlier. |
| 122 | .\" |
| 123 | .El |
| 124 | .Sh RETURN VALUES |
| 125 | .Nm |
| 126 | returns the value returned by the called compiler unless |
| 127 | .Fl -status-bugs |
| 128 | is used. |
| 129 | .\" |
| 130 | .\" Other sections not yet used ... |
| 131 | .\" .Sh ENVIRONMENT |
| 132 | .\" .Sh FILES |
| 133 | .\" .Sh DIAGNOSTICS |
| 134 | .\" .Sh COMPATIBILITY |
| 135 | .\" .Sh HISTORY |
| 136 | .\" .Sh AUTHORS |
| 137 | .\" .Sh BUGS |
| 138 | .\" |
| 139 | .Sh CONTROLLING CHECKERS |
| 140 | A default group of checkers are always run unless explicitly disabled. |
| 141 | The checkers listed below may be enabled/disabled using the |
| 142 | .Fl enable-checker |
| 143 | and |
| 144 | .Fl disable-checker |
| 145 | options. |
| 146 | .Bl -tag -width indent |
| 147 | .It core.AdjustedReturnValue |
| 148 | Check to see if the return value of a function call is different than |
| 149 | the caller expects (e.g., from calls through function pointers) |
| 150 | .Bq on |
| 151 | .It core.AttributeNonNull |
| 152 | Check for null pointers passed as arguments to a function whose arguments are marked with the |
| 153 | .Qlnonnull' attribute |
| 154 | .Bq on |
| 155 | .It core.CallAndMessage |
| 156 | Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers) |
| 157 | .Bq on |
| 158 | .It core.DivideZero |
| 159 | Check for division by zero |
| 160 | .Bq on |
| 161 | .It core.NullDereference |
| 162 | Check for dereferences of null pointers |
| 163 | .Bq on |
| 164 | .It core.StackAddressEscape |
| 165 | Check that addresses to stack memory do not escape the function |
| 166 | .Bq on |
| 167 | .It core.UndefinedBinaryOperatorResult |
| 168 | Check for undefined results of binary operators |
| 169 | .Bq on |
| 170 | .It core.VLASize |
| 171 | Check for declarations of VLA of undefined or zero size |
| 172 | .Bq on |
| 173 | .It core.builtin.BuiltinFunctions |
| 174 | Evaluate compiler builtin functions (e.g., alloca()) |
| 175 | .Bq on |
| 176 | .It core.builtin.NoReturnFunctions Evaluate "panic" functions that are known to not return to the caller |
| 177 | .Bq on |
| 178 | .It core.uninitialized.ArraySubscript |
| 179 | Check for uninitialized values used as array subscripts |
| 180 | .Bq on |
| 181 | .It core.uninitialized.Assign |
| 182 | Check for assigning uninitialized values |
| 183 | .Bq on |
| 184 | .It core.uninitialized.Bqanch |
| 185 | Check for uninitialized values used as branch conditions |
| 186 | .Bq on |
| 187 | .It core.uninitialized.CapturedBlockVariable |
| 188 | Check for blocks that capture uninitialized values |
| 189 | .Bq on |
| 190 | .It core.uninitialized.UndefReturn Check for uninitialized values being returned to the caller |
| 191 | .Bq on |
| 192 | .It deadcode.DeadStores |
| 193 | Check for values stored to variables that are never read afterwards |
| 194 | .Bq off |
| 195 | .It debug.DumpCFG |
| 196 | Display Control-Flow Graphs |
| 197 | .Bq off |
| 198 | .It debug.DumpCallGraph |
| 199 | Display Call Graph |
| 200 | .Bq off |
| 201 | .It debug.DumpDominators |
| 202 | Print the dominance tree for a given CFG |
| 203 | .Bq off |
| 204 | .It debug.DumpLiveVars |
| 205 | Print results of live variable analysis |
| 206 | .Bq off |
| 207 | .It debug.Stats |
| 208 | Emit warnings with analyzer statistics |
| 209 | .Bq off |
| 210 | .It debug.TaintTest |
| 211 | Mark tainted symbols as such. |
| 212 | .Bq off |
| 213 | .It debug.ViewCFG |
| 214 | View Control-Flow Graphs using GraphViz |
| 215 | .Bq off |
| 216 | .It debug.ViewCallGraph |
| 217 | View Call Graph using GraphViz |
| 218 | .Bq off |
| 219 | .It llvm.Conventions |
| 220 | Check code for LLVM codebase conventions |
| 221 | .Bq off |
| 222 | .It osx.API |
| 223 | Check for proper uses of various Mac OS X APIs |
| 224 | .Bq off |
| 225 | .It osx.AtomicCAS |
| 226 | Evaluate calls to OSAtomic functions |
| 227 | .Bq off |
| 228 | .It osx.SecKeychainAPI |
| 229 | Check for proper uses of Secure Keychain APIs |
| 230 | .Bq off |
| 231 | .It osx.cocoa.AtSync |
| 232 | Check for null pointers used as mutexes for @synchronized |
| 233 | .Bq off |
| 234 | .It osx.cocoa.ClassRelease |
| 235 | Check for sending 'retain', 'release', or 'autorelease' directly to a Class |
| 236 | .Bq off |
| 237 | .It osx.cocoa.IncompatibleMethodTypes |
| 238 | Warn about Objective-C method signatures with type incompatibilities |
| 239 | .Bq off |
| 240 | .It osx.cocoa.NSAutoreleasePool |
| 241 | Warn for suboptimal uses of NSAutoreleasePool in Objective-C GC mode |
| 242 | .Bq off |
| 243 | .It osx.cocoa.NSError |
| 244 | Check usage of NSError** parameters |
| 245 | .Bq off |
| 246 | .It osx.cocoa.NilArg |
| 247 | Check for prohibited nil arguments to ObjC method calls |
| 248 | .Bq off |
| 249 | .It osx.cocoa.RetainCount |
| 250 | Check for leaks and improper reference count management |
| 251 | .Bq off |
| 252 | .It osx.cocoa.SelfInit |
| 253 | Check that 'self' is properly initialized inside an initializer method |
| 254 | .Bq off |
| 255 | .It osx.cocoa.UnusedIvars |
| 256 | Warn about private ivars that are never used |
| 257 | .Bq off |
| 258 | .It osx.cocoa.VariadicMethodTypes |
| 259 | Check for passing non-Objective-C types to variadic methods that expect only Objective-C types |
| 260 | .Bq off |
| 261 | .It osx.coreFoundation.CFError |
| 262 | Check usage of CFErrorRef* parameters |
| 263 | .Bq off |
| 264 | .It osx.coreFoundation.CFNumber |
| 265 | Check for proper uses of CFNumberCreate |
| 266 | .Bq off |
| 267 | .It osx.coreFoundation.CFRetainRelease |
| 268 | Check for null arguments to CFRetain/CFRelease |
| 269 | .Bq off |
| 270 | .It osx.coreFoundation.containers.OutOfBounds |
| 271 | Checks for index out-of-bounds when using 'CFArray' API |
| 272 | .Bq off |
| 273 | .It osx.coreFoundation.containers.PointerSizedValues |
| 274 | Warns if 'CFArray', 'CFDictionary', 'CFSet' are created with non-pointer-size values |
| 275 | .Bq off |
| 276 | .It security.FloatLoopCounter |
| 277 | Warn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP) |
| 278 | .Bq off |
| 279 | .It security.insecureAPI.UncheckedReturn |
| 280 | Warn on uses of functions whose return values must be always checked |
| 281 | .Bq off |
| 282 | .It security.insecureAPI.getpw |
| 283 | Warn on uses of the 'getpw' function |
| 284 | .Bq off |
| 285 | .It security.insecureAPI.gets |
| 286 | Warn on uses of the 'gets' function |
| 287 | .Bq off |
| 288 | .It security.insecureAPI.mkstemp |
| 289 | Warn when 'mkstemp' is passed fewer than 6 X's in the format string |
| 290 | .Bq off |
| 291 | .It security.insecureAPI.mktemp |
| 292 | Warn on uses of the 'mktemp' function |
| 293 | .Bq off |
| 294 | .It security.insecureAPI.rand |
| 295 | Warn on uses of the 'rand', 'random', and related functions |
| 296 | .Bq off |
| 297 | .It security.insecureAPI.strcpy |
| 298 | Warn on uses of the 'strcpy' and 'strcat' functions |
| 299 | .Bq off |
| 300 | .It security.insecureAPI.vfork |
| 301 | Warn on uses of the 'vfork' function |
| 302 | .Bq off |
| 303 | .It unix.API |
| 304 | Check calls to various UNIX/Posix functions |
| 305 | .Bq off |
| 306 | .It unix.Malloc |
| 307 | Check for memory leaks, double free, and use-after-free problems. |
| 308 | .Bq off |
| 309 | .It unix.cstring.BadSizeArg |
| 310 | Check the size argument passed into C string functions for common erroneous patterns |
| 311 | .Bq off |
| 312 | .It unix.cstring.NullArg |
| 313 | Check for null pointers being passed as arguments to C string functions |
| 314 | .Bq off |
| 315 | .El |
| 316 | .\" |
| 317 | .Sh EXAMPLE |
| 318 | .Ic scan-build -o /tmp/myhtmldir make -j4 |
| 319 | .Pp |
| 320 | The above example causes analysis reports to be deposited into |
| 321 | a subdirectory of |
| 322 | .Ql /tmp/myhtmldir |
| 323 | and to run |
| 324 | .Ql make |
| 325 | with the |
| 326 | .Ql -j4 |
| 327 | option. |
| 328 | A different subdirectory is created each time |
| 329 | .Nm |
| 330 | analyzes a project. |
| 331 | The analyzer should support most parallel builds, but not distributed builds. |
| 332 | |