xref: /minix3/external/bsd/llvm/dist/clang/tools/scan-build/scan-build.1 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc.\" This file is distributed under the University of Illinois Open Source
2f4a2713aSLionel Sambuc.\" License. See LICENSE.TXT for details.
3*0a6a1f1dSLionel Sambuc.\" $Id: scan-build.1,v 1.1.1.2 2014/03/04 19:53:21 joerg Exp $
4f4a2713aSLionel Sambuc.Dd May 25, 2012
5f4a2713aSLionel Sambuc.Dt SCAN-BUILD 1
6*0a6a1f1dSLionel Sambuc.Os "clang" "3.5"
7f4a2713aSLionel Sambuc.Sh NAME
8f4a2713aSLionel Sambuc.Nm scan-build
9f4a2713aSLionel Sambuc.Nd Clang static analyzer
10f4a2713aSLionel Sambuc.Sh SYNOPSIS
11f4a2713aSLionel Sambuc.Nm
12f4a2713aSLionel Sambuc.Op Fl ohkvV
13f4a2713aSLionel Sambuc.Op Fl analyze-headers
14f4a2713aSLionel Sambuc.Op Fl enable-checker Op Ar checker_name
15f4a2713aSLionel Sambuc.Op Fl disable-checker Op Ar checker_name
16f4a2713aSLionel Sambuc.Op Fl Fl help
17f4a2713aSLionel Sambuc.Op Fl Fl help-checkers
18f4a2713aSLionel Sambuc.Op Fl Fl html-title Op Ar =title
19f4a2713aSLionel Sambuc.Op Fl Fl keep-going
20f4a2713aSLionel Sambuc.Op Fl plist
21f4a2713aSLionel Sambuc.Op Fl plist-html
22f4a2713aSLionel Sambuc.Op Fl Fl status-bugs
23f4a2713aSLionel Sambuc.Op Fl Fl use-c++ Op Ar =compiler_path
24f4a2713aSLionel Sambuc.Op Fl Fl use-cc Op Ar =compiler_path
25f4a2713aSLionel Sambuc.Op Fl Fl view
26f4a2713aSLionel Sambuc.Op Fl constraints Op Ar model
27f4a2713aSLionel Sambuc.Op Fl maxloop Ar N
28f4a2713aSLionel Sambuc.Op Fl no-failure-reports
29f4a2713aSLionel Sambuc.Op Fl stats
30f4a2713aSLionel Sambuc.Op Fl store Op Ar model
31f4a2713aSLionel Sambuc.Ar build_command
32f4a2713aSLionel Sambuc.Op build_options
33f4a2713aSLionel Sambuc.\"
34f4a2713aSLionel Sambuc.\" Sh DESCRIPTION
35f4a2713aSLionel Sambuc.Sh DESCRIPTION
36f4a2713aSLionel Sambuc.Nm
37f4a2713aSLionel Sambucis a Perl script that invokes the Clang static analyzer.  Options used by
38f4a2713aSLionel Sambuc.Nm
39f4a2713aSLionel Sambucor by the analyzer appear first, followed by the
40f4a2713aSLionel Sambuc.Ar build_command
41f4a2713aSLionel Sambucand any
42f4a2713aSLionel Sambuc.Ar build_options
43f4a2713aSLionel Sambucnormally used to build the target system.
44f4a2713aSLionel Sambuc.Pp
45f4a2713aSLionel SambucThe static analyzer employs a long list of checking algorithms, see
46f4a2713aSLionel Sambuc.Sx CHECKERS .
47f4a2713aSLionel SambucOutput can be written in standard
48f4a2713aSLionel Sambuc.Li .plist
49f4a2713aSLionel Sambucand/or HTML format.
50f4a2713aSLionel Sambuc.Pp
51f4a2713aSLionel SambucThe following options are supported:
52f4a2713aSLionel Sambuc.Bl -tag -width indent
53f4a2713aSLionel Sambuc.It Fl analyze-headers
54f4a2713aSLionel SambucAlso analyze functions in #included files.
55f4a2713aSLionel Sambuc.It Fl enable-checker Ar checker_name , Fl disable-checker Ar checker_name
56f4a2713aSLionel SambucEnable/disable
57f4a2713aSLionel Sambuc.Ar checker_name .
58f4a2713aSLionel SambucSee
59f4a2713aSLionel Sambuc.Sx CHECKERS .
60f4a2713aSLionel Sambuc.It Fl h , Fl Fl help
61f4a2713aSLionel SambucDisplay this message.
62f4a2713aSLionel Sambuc.It Fl Fl help-checkers
63f4a2713aSLionel SambucList default checkers, see
64f4a2713aSLionel Sambuc.Sx CHECKERS .
65f4a2713aSLionel Sambuc.It Fl Fl html-title Ns Op = Ns Ar title
66f4a2713aSLionel SambucSpecify the title used on generated HTML pages.
67f4a2713aSLionel SambucA default title is generated if
68f4a2713aSLionel Sambuc.Ar title
69f4a2713aSLionel Sambucis not specified.
70f4a2713aSLionel Sambuc.It Fl k , Fl Fl keep-going
71f4a2713aSLionel SambucAdd a
72f4a2713aSLionel Sambuc.Dq keep on going
73f4a2713aSLionel Sambucoption to
74f4a2713aSLionel Sambuc.Ar build_command .
75f4a2713aSLionel SambucCurrently supports make and xcodebuild. This is a convenience option;
76f4a2713aSLionel Sambucone can specify this behavior directly using build options.
77f4a2713aSLionel Sambuc.It Fl o
78f4a2713aSLionel SambucTarget directory for HTML report files.  Subdirectories will be
79f4a2713aSLionel Sambuccreated as needed to represent separate invocations
80f4a2713aSLionel Sambucof the analyzer.  If this option is not specified, a directory is
81f4a2713aSLionel Sambuccreated in /tmp (TMPDIR on Mac OS X) to store the reports.
82f4a2713aSLionel Sambuc.It Fl plist
83f4a2713aSLionel SambucOutput the results as a set of
84f4a2713aSLionel Sambuc.Li .plist
85f4a2713aSLionel Sambucfiles. (By default the output of
86f4a2713aSLionel Sambuc.Nm
87f4a2713aSLionel Sambucis a set of HTML files.)
88f4a2713aSLionel Sambuc.It Fl plist-html
89f4a2713aSLionel SambucOutput the results as a set of HTML and .plist files
90f4a2713aSLionel Sambuc.It Fl Fl status-bugs
91f4a2713aSLionel SambucSet exit status to 1 if it found potential bugs and 0 otherwise. By
92f4a2713aSLionel Sambucdefault the exit status of
93f4a2713aSLionel Sambuc.Nm
94f4a2713aSLionel Sambucis that returned by
95f4a2713aSLionel Sambuc.Ar build_command .
96f4a2713aSLionel Sambuc.It Fl Fl use-c++ Ns Op = Ns Ar compiler_path
97f4a2713aSLionel SambucGuess the default compiler for your C++ and Objective-C++ code. Use this
98f4a2713aSLionel Sambucoption to specify an alternate compiler.
99f4a2713aSLionel Sambuc.It Fl Fl use-cc Ns Op = Ns Ar compiler_path
100f4a2713aSLionel SambucGuess the default compiler for your C and Objective-C code. Use this
101f4a2713aSLionel Sambucoption to specify an alternate compiler.
102f4a2713aSLionel Sambuc.It Fl v
103f4a2713aSLionel SambucVerbose output from
104f4a2713aSLionel Sambuc.Nm
105f4a2713aSLionel Sambucand the analyzer. A second and
106f4a2713aSLionel Sambucthird
107f4a2713aSLionel Sambuc.Ar v
108f4a2713aSLionel Sambucincreases verbosity.
109f4a2713aSLionel Sambuc.It Fl V , Fl Fl view
110f4a2713aSLionel SambucView analysis results in a web browser when the build completes.
111f4a2713aSLionel Sambuc.It Fl constraints Op Ar model
112f4a2713aSLionel SambucSpecify the contraint engine used by the analyzer.  By default the
113f4a2713aSLionel Sambuc.Ql range
114f4a2713aSLionel Sambucmodel is used.  Specifying
115f4a2713aSLionel Sambuc.Ql basic
116f4a2713aSLionel Sambucuses a simpler, less powerful constraint model used by checker-0.160
117f4a2713aSLionel Sambucand earlier.
118f4a2713aSLionel Sambuc.It Fl maxloop Ar N
119f4a2713aSLionel SambucSpecifiy the number of times a block can be visited before giving
120f4a2713aSLionel Sambucup. Default is 4. Increase for more comprehensive coverage at a
121f4a2713aSLionel Sambuccost of speed.
122f4a2713aSLionel Sambuc.It Fl no-failure-reports
123f4a2713aSLionel SambucDo not create a
124f4a2713aSLionel Sambuc.Ql failures
125f4a2713aSLionel Sambucsubdirectory that includes analyzer crash reports and preprocessed
126f4a2713aSLionel Sambucsource files.
127f4a2713aSLionel Sambuc.It Fl stats
128f4a2713aSLionel SambucGenerates visitation statistics for the project being analyzed.
129f4a2713aSLionel Sambuc.It Fl store Op Ar model
130f4a2713aSLionel SambucSpecify the store model used by the analyzer. By default, the
131f4a2713aSLionel Sambuc.Ql region
132f4a2713aSLionel Sambucstore model is used.
133f4a2713aSLionel Sambuc.Ql region
134f4a2713aSLionel Sambucspecifies a field-
135f4a2713aSLionel Sambucsensitive store model. Users can also specify
136f4a2713aSLionel Sambuc.Ql basic
137f4a2713aSLionel Sambucwhich is far less precise but can more quickly analyze code.
138f4a2713aSLionel Sambuc.Ql basic
139f4a2713aSLionel Sambucwas the default store model for checker-0.221 and earlier.
140f4a2713aSLionel Sambuc.\"
141f4a2713aSLionel Sambuc.El
142f4a2713aSLionel Sambuc.Sh EXIT STATUS
143f4a2713aSLionel Sambuc.Nm
144f4a2713aSLionel Sambucreturns the value returned by
145f4a2713aSLionel Sambuc.Ar build_command
146f4a2713aSLionel Sambucunless
147f4a2713aSLionel Sambuc.Fl Fl status-bugs
148f4a2713aSLionel Sambucor
149f4a2713aSLionel Sambuc.Fl Fl keep-going
150f4a2713aSLionel Sambucis used.
151f4a2713aSLionel Sambuc.\"
152f4a2713aSLionel Sambuc.\" Other sections not yet used ...
153f4a2713aSLionel Sambuc.\" .Sh ENVIRONMENT
154f4a2713aSLionel Sambuc.\" .Sh FILES
155f4a2713aSLionel Sambuc.\" .Sh DIAGNOSTICS
156f4a2713aSLionel Sambuc.\" .Sh COMPATIBILITY
157f4a2713aSLionel Sambuc.\" .Sh HISTORY
158f4a2713aSLionel Sambuc.\" .Sh BUGS
159f4a2713aSLionel Sambuc.\"
160f4a2713aSLionel Sambuc.Sh CHECKERS
161f4a2713aSLionel SambucThe checkers listed below may be enabled/disabled using the
162f4a2713aSLionel Sambuc.Fl enable-checker
163f4a2713aSLionel Sambucand
164f4a2713aSLionel Sambuc.Fl disable-checker
165f4a2713aSLionel Sambucoptions.
166f4a2713aSLionel SambucA default group of checkers is run unless explicitly disabled.
167f4a2713aSLionel SambucExactly which checkers constitute the default group is a function
168f4a2713aSLionel Sambucof the operating system in use; they are listed with
169f4a2713aSLionel Sambuc.Fl Fl help-checkers .
170f4a2713aSLionel Sambuc.Bl -tag -width indent.
171f4a2713aSLionel Sambuc.It core.AdjustedReturnValue
172f4a2713aSLionel SambucCheck to see if the return value of a function call is different than
173f4a2713aSLionel Sambucthe caller expects (e.g., from calls through function pointers).
174f4a2713aSLionel Sambuc.It core.AttributeNonNull
175f4a2713aSLionel SambucCheck for null pointers passed as arguments to a function whose arguments are marked with the
176f4a2713aSLionel Sambuc.Ql nonnull
177f4a2713aSLionel Sambucattribute.
178f4a2713aSLionel Sambuc.It core.CallAndMessage
179f4a2713aSLionel SambucCheck for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers).
180f4a2713aSLionel Sambuc.It core.DivideZero
181f4a2713aSLionel SambucCheck for division by zero.
182f4a2713aSLionel Sambuc.It core.NullDereference
183f4a2713aSLionel SambucCheck for dereferences of null pointers.
184f4a2713aSLionel Sambuc.It core.StackAddressEscape
185f4a2713aSLionel SambucCheck that addresses to stack memory do not escape the function.
186f4a2713aSLionel Sambuc.It core.UndefinedBinaryOperatorResult
187f4a2713aSLionel SambucCheck for undefined results of binary operators.
188f4a2713aSLionel Sambuc.It core.VLASize
189f4a2713aSLionel SambucCheck for declarations of VLA of undefined or zero size.
190f4a2713aSLionel Sambuc.It core.builtin.BuiltinFunctions
191f4a2713aSLionel SambucEvaluate compiler builtin functions, e.g.
192f4a2713aSLionel Sambuc.Fn alloca .
193f4a2713aSLionel Sambuc.It core.builtin.NoReturnFunctions
194f4a2713aSLionel SambucEvaluate
195f4a2713aSLionel Sambuc.Ql panic
196f4a2713aSLionel Sambucfunctions that are known to not return to the caller.
197f4a2713aSLionel Sambuc.It core.uninitialized.ArraySubscript
198f4a2713aSLionel SambucCheck for uninitialized values used as array subscripts.
199f4a2713aSLionel Sambuc.It core.uninitialized.Assign
200f4a2713aSLionel SambucCheck for assigning uninitialized values.
201f4a2713aSLionel Sambuc.It core.uninitialized.Branch
202f4a2713aSLionel SambucCheck for uninitialized values used as branch conditions.
203f4a2713aSLionel Sambuc.It core.uninitialized.CapturedBlockVariable
204f4a2713aSLionel SambucCheck for blocks that capture uninitialized values.
205f4a2713aSLionel Sambuc.It core.uninitialized.UndefReturn
206f4a2713aSLionel SambucCheck for uninitialized values being returned to the caller.
207f4a2713aSLionel Sambuc.It deadcode.DeadStores
208f4a2713aSLionel SambucCheck for values stored to variables that are never read afterwards.
209f4a2713aSLionel Sambuc.It debug.DumpCFG
210f4a2713aSLionel SambucDisplay Control-Flow Graphs.
211f4a2713aSLionel Sambuc.It debug.DumpCallGraph
212f4a2713aSLionel SambucDisplay Call Graph.
213f4a2713aSLionel Sambuc.It debug.DumpDominators
214f4a2713aSLionel SambucPrint the dominance tree for a given Control-Flow Graph.
215f4a2713aSLionel Sambuc.It debug.DumpLiveVars
216f4a2713aSLionel SambucPrint results of live variable analysis.
217f4a2713aSLionel Sambuc.It debug.Stats
218f4a2713aSLionel SambucEmit warnings with analyzer statistics.
219f4a2713aSLionel Sambuc.It debug.TaintTest
220f4a2713aSLionel SambucMark tainted symbols as such.
221f4a2713aSLionel Sambuc.It debug.ViewCFG
222f4a2713aSLionel SambucView Control-Flow Graphs using
223f4a2713aSLionel Sambuc.Ic GraphViz .
224f4a2713aSLionel Sambuc.It debug.ViewCallGraph
225f4a2713aSLionel SambucView Call Graph using
226f4a2713aSLionel Sambuc.Ic GraphViz .
227f4a2713aSLionel Sambuc.It llvm.Conventions
228f4a2713aSLionel SambucCheck code for LLVM codebase conventions.
229f4a2713aSLionel Sambuc.It osx.API
230f4a2713aSLionel SambucCheck for proper uses of various Mac OS X APIs.
231f4a2713aSLionel Sambuc.It osx.AtomicCAS
232f4a2713aSLionel SambucEvaluate calls to
233f4a2713aSLionel Sambuc.Vt OSAtomic
234f4a2713aSLionel Sambucfunctions.
235f4a2713aSLionel Sambuc.It osx.SecKeychainAPI
236f4a2713aSLionel SambucCheck for proper uses of Secure Keychain APIs.
237f4a2713aSLionel Sambuc.It osx.cocoa.AtSync
238f4a2713aSLionel SambucCheck for null pointers used as mutexes for @synchronized.
239f4a2713aSLionel Sambuc.It osx.cocoa.ClassRelease
240f4a2713aSLionel SambucCheck for sending
241f4a2713aSLionel Sambuc.Ql retain ,
242f4a2713aSLionel Sambuc.Ql release,
243f4a2713aSLionel Sambucor
244f4a2713aSLionel Sambuc.Ql autorelease
245f4a2713aSLionel Sambucdirectly to a Class.
246f4a2713aSLionel Sambuc.It osx.cocoa.IncompatibleMethodTypes
247f4a2713aSLionel SambucWarn about Objective-C method signatures with type incompatibilities.
248f4a2713aSLionel Sambuc.It osx.cocoa.NSAutoreleasePool
249f4a2713aSLionel SambucWarn for suboptimal uses of
250f4a2713aSLionel Sambuc.Vt NSAutoreleasePool
251f4a2713aSLionel Sambucin Objective-C GC mode.
252f4a2713aSLionel Sambuc.It osx.cocoa.NSError
253f4a2713aSLionel SambucCheck usage of NSError** parameters.
254f4a2713aSLionel Sambuc.It osx.cocoa.NilArg
255f4a2713aSLionel SambucCheck for prohibited nil arguments to Objective-C method calls.
256f4a2713aSLionel Sambuc.It osx.cocoa.RetainCount
257f4a2713aSLionel SambucCheck for leaks and improper reference count management.
258f4a2713aSLionel Sambuc.It osx.cocoa.SelfInit
259f4a2713aSLionel SambucCheck that
260f4a2713aSLionel Sambuc.Ql self
261f4a2713aSLionel Sambucis properly initialized inside an initializer method.
262f4a2713aSLionel Sambuc.It osx.cocoa.UnusedIvars
263f4a2713aSLionel SambucWarn about private ivars that are never used.
264f4a2713aSLionel Sambuc.It osx.cocoa.VariadicMethodTypes
265f4a2713aSLionel SambucCheck for passing non-Objective-C types to variadic methods that expect only Objective-C types.
266f4a2713aSLionel Sambuc.It osx.coreFoundation.CFError
267f4a2713aSLionel SambucCheck usage of CFErrorRef* parameters.
268f4a2713aSLionel Sambuc.It osx.coreFoundation.CFNumber
269f4a2713aSLionel SambucCheck for proper uses of
270f4a2713aSLionel Sambuc.Fn CFNumberCreate .
271f4a2713aSLionel Sambuc.It osx.coreFoundation.CFRetainRelease
272f4a2713aSLionel SambucCheck for null arguments to
273f4a2713aSLionel Sambuc.Fn CFRetain ,
274f4a2713aSLionel Sambuc.Fn CFRelease ,
275f4a2713aSLionel Sambucand
276f4a2713aSLionel Sambuc.Fn CFMakeCollectable .
277f4a2713aSLionel Sambuc.It osx.coreFoundation.containers.OutOfBounds
278f4a2713aSLionel SambucChecks for index out-of-bounds when using the
279f4a2713aSLionel Sambuc.Vt CFArray
280f4a2713aSLionel SambucAPI.
281f4a2713aSLionel Sambuc.It osx.coreFoundation.containers.PointerSizedValues
282f4a2713aSLionel SambucWarns if
283f4a2713aSLionel Sambuc.Vt CFArray ,
284f4a2713aSLionel Sambuc.Vt CFDictionary ,
285f4a2713aSLionel Sambucor
286f4a2713aSLionel Sambuc.Vt CFSet
287f4a2713aSLionel Sambucare created with non-pointer-size values.
288f4a2713aSLionel Sambuc.It security.FloatLoopCounter
289f4a2713aSLionel SambucWarn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP).
290f4a2713aSLionel Sambuc.It security.insecureAPI.UncheckedReturn
291f4a2713aSLionel SambucWarn on uses of functions whose return values must be always checked.
292f4a2713aSLionel Sambuc.It security.insecureAPI.getpw
293f4a2713aSLionel SambucWarn on uses of
294f4a2713aSLionel Sambuc.Fn getpw .
295f4a2713aSLionel Sambuc.It security.insecureAPI.gets
296f4a2713aSLionel SambucWarn on uses of
297f4a2713aSLionel Sambuc.Fn gets .
298f4a2713aSLionel Sambuc.It security.insecureAPI.mkstemp
299f4a2713aSLionel SambucWarn when
300f4a2713aSLionel Sambuc.Fn mkstemp
301f4a2713aSLionel Sambucis passed fewer than 6 X's in the format string.
302f4a2713aSLionel Sambuc.It security.insecureAPI.mktemp
303f4a2713aSLionel SambucWarn on uses of
304f4a2713aSLionel Sambuc.Fn mktemp .
305f4a2713aSLionel Sambuc.It security.insecureAPI.rand
306f4a2713aSLionel SambucWarn on uses of
307f4a2713aSLionel Sambuc.Fn rand ,
308f4a2713aSLionel Sambuc.Fn random ,
309f4a2713aSLionel Sambucand related functions.
310f4a2713aSLionel Sambuc.It security.insecureAPI.strcpy
311f4a2713aSLionel SambucWarn on uses of
312f4a2713aSLionel Sambuc.Fn strcpy
313f4a2713aSLionel Sambucand
314f4a2713aSLionel Sambuc.Fn strcat .
315f4a2713aSLionel Sambuc.It security.insecureAPI.vfork
316f4a2713aSLionel SambucWarn on uses of
317f4a2713aSLionel Sambuc.Fn vfork .
318f4a2713aSLionel Sambuc.It unix.API
319f4a2713aSLionel SambucCheck calls to various UNIX/Posix functions.
320f4a2713aSLionel Sambuc.It unix.Malloc
321f4a2713aSLionel SambucCheck for memory leaks, double free, and use-after-free.
322f4a2713aSLionel Sambuc.It unix.cstring.BadSizeArg
323f4a2713aSLionel SambucCheck the size argument passed into C string functions for common
324f4a2713aSLionel Sambucerroneous patterns.
325f4a2713aSLionel Sambuc.It unix.cstring.NullArg
326f4a2713aSLionel SambucCheck for null pointers being passed as arguments to C string functions.
327f4a2713aSLionel Sambuc.El
328f4a2713aSLionel Sambuc.\"
329f4a2713aSLionel Sambuc.Sh EXAMPLE
330f4a2713aSLionel Sambuc.Ic scan-build -o /tmp/myhtmldir make -j4
331f4a2713aSLionel Sambuc.Pp
332f4a2713aSLionel SambucThe above example causes analysis reports to be deposited into
333f4a2713aSLionel Sambuca subdirectory of
334f4a2713aSLionel Sambuc.Pa /tmp/myhtmldir
335f4a2713aSLionel Sambucand to run
336f4a2713aSLionel Sambuc.Ic make
337f4a2713aSLionel Sambucwith the
338f4a2713aSLionel Sambuc.Fl j4
339f4a2713aSLionel Sambucoption.
340f4a2713aSLionel SambucA different subdirectory is created each time
341f4a2713aSLionel Sambuc.Nm
342f4a2713aSLionel Sambucanalyzes a project.
343f4a2713aSLionel SambucThe analyzer should support most parallel builds, but not distributed builds.
344f4a2713aSLionel Sambuc.Sh AUTHORS
345f4a2713aSLionel Sambuc.Nm
346f4a2713aSLionel Sambucwas written by
347f4a2713aSLionel Sambuc.An "Ted Kremenek" .
348f4a2713aSLionel SambucDocumentation contributed by
349f4a2713aSLionel Sambuc.An "James K. Lowden" Aq jklowden@schemamania.org .
350