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