1 .\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 .\" See https://llvm.org/LICENSE.txt for license information.
3 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 .Nd Clang static analyzer
14 .Op Fl analyze-headers
15 .Op Fl enable-checker Op Ar checker_name
16 .Op Fl disable-checker Op Ar checker_name
18 .Op Fl Fl help-checkers
19 .Op Fl Fl html-title Op Ar =title
24 .Op Fl Fl use-c++ Op Ar =compiler_path
25 .Op Fl Fl use-cc Op Ar =compiler_path
27 .Op Fl constraints Op Ar model
29 .Op Fl no-failure-reports
31 .Op Fl store Op Ar model
38 is a Perl script that invokes the Clang static analyzer. Options used by
40 or by the analyzer appear first, followed by the
44 normally used to build the target system.
46 The static analyzer employs a long list of checking algorithms, see
48 Output can be written in standard
52 The following options are supported:
53 .Bl -tag -width indent
54 .It Fl analyze-headers
55 Also analyze functions in #included files.
56 .It Fl enable-checker Ar checker_name , Fl disable-checker Ar checker_name
63 .It Fl Fl help-checkers
64 List default checkers, see
66 .It Fl Fl html-title Ns Op = Ns Ar title
67 Specify the title used on generated HTML pages.
68 A default title is generated if
71 .It Fl k , Fl Fl keep-going
76 Currently supports make and xcodebuild. This is a convenience option;
77 one can specify this behavior directly using build options.
79 Target directory for HTML report files. Subdirectories will be
80 created as needed to represent separate invocations
81 of the analyzer. If this option is not specified, a directory is
82 created in /tmp (TMPDIR on Mac OS X) to store the reports.
84 Output the results as a set of
86 files. (By default the output of
88 is a set of HTML files.)
90 Output the results as a set of HTML and .plist files
92 Set exit status to 1 if it found potential bugs and 0 otherwise. By
93 default the exit status of
97 .It Fl Fl use-c++ Ns Op = Ns Ar compiler_path
98 Guess the default compiler for your C++ and Objective-C++ code. Use this
99 option to specify an alternate compiler.
100 .It Fl Fl use-cc Ns Op = Ns Ar compiler_path
101 Guess the default compiler for your C and Objective-C code. Use this
102 option to specify an alternate compiler.
106 and the analyzer. A second and
110 .It Fl V , Fl Fl view
111 View analysis results in a web browser when the build completes.
112 .It Fl constraints Op Ar model
113 Specify the constraint engine used by the analyzer. By default the
115 model is used. Specifying
117 uses a simpler, less powerful constraint model used by checker-0.160
120 Specify the number of times a block can be visited before giving
121 up. Default is 4. Increase for more comprehensive coverage at a
123 .It Fl no-failure-reports
126 subdirectory that includes analyzer crash reports and preprocessed
129 Generates visitation statistics for the project being analyzed.
130 .It Fl store Op Ar model
131 Specify the store model used by the analyzer. By default, the
136 sensitive store model. Users can also specify
138 which is far less precise but can more quickly analyze code.
140 was the default store model for checker-0.221 and earlier.
145 returns the value returned by
153 .\" Other sections not yet used ...
157 .\" .Sh COMPATIBILITY
162 The checkers listed below may be enabled/disabled using the
167 A default group of checkers is run unless explicitly disabled.
168 Exactly which checkers constitute the default group is a function
169 of the operating system in use; they are listed with
170 .Fl Fl help-checkers .
171 .Bl -tag -width indent.
172 .It core.AdjustedReturnValue
173 Check to see if the return value of a function call is different than
174 the caller expects (e.g., from calls through function pointers).
175 .It core.AttributeNonNull
176 Check for null pointers passed as arguments to a function whose arguments are marked with the
179 .It core.CallAndMessage
180 Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers).
182 Check for division by zero.
183 .It core.NullDereference
184 Check for dereferences of null pointers.
185 .It core.StackAddressEscape
186 Check that addresses to stack memory do not escape the function.
187 .It core.UndefinedBinaryOperatorResult
188 Check for undefined results of binary operators.
190 Check for declarations of VLA of undefined or zero size.
191 .It core.builtin.BuiltinFunctions
192 Evaluate compiler builtin functions, e.g.
194 .It core.builtin.NoReturnFunctions
197 functions that are known to not return to the caller.
198 .It core.uninitialized.ArraySubscript
199 Check for uninitialized values used as array subscripts.
200 .It core.uninitialized.Assign
201 Check for assigning uninitialized values.
202 .It core.uninitialized.Branch
203 Check for uninitialized values used as branch conditions.
204 .It core.uninitialized.CapturedBlockVariable
205 Check for blocks that capture uninitialized values.
206 .It core.uninitialized.UndefReturn
207 Check for uninitialized values being returned to the caller.
208 .It deadcode.DeadStores
209 Check for values stored to variables that are never read afterwards.
211 Display Control-Flow Graphs.
212 .It debug.DumpCallGraph
214 .It debug.DumpDominators
215 Print the dominance tree for a given Control-Flow Graph.
216 .It debug.DumpLiveVars
217 Print results of live variable analysis.
219 Emit warnings with analyzer statistics.
221 Mark tainted symbols as such.
223 View Control-Flow Graphs using
225 .It debug.ViewCallGraph
226 View Call Graph using
229 Check code for LLVM codebase conventions.
231 Check for proper uses of various Mac OS X APIs.
236 .It osx.SecKeychainAPI
237 Check for proper uses of Secure Keychain APIs.
239 Check for null pointers used as mutexes for @synchronized.
240 .It osx.cocoa.ClassRelease
247 .It osx.cocoa.IncompatibleMethodTypes
248 Warn about Objective-C method signatures with type incompatibilities.
249 .It osx.cocoa.NSAutoreleasePool
250 Warn for suboptimal uses of
251 .Vt NSAutoreleasePool
252 in Objective-C GC mode.
253 .It osx.cocoa.NSError
254 Check usage of NSError** parameters.
256 Check for prohibited nil arguments to Objective-C method calls.
257 .It osx.cocoa.RetainCount
258 Check for leaks and improper reference count management.
259 .It osx.cocoa.SelfInit
262 is properly initialized inside an initializer method.
263 .It osx.cocoa.UnusedIvars
264 Warn about private ivars that are never used.
265 .It osx.cocoa.VariadicMethodTypes
266 Check for passing non-Objective-C types to variadic methods that expect only Objective-C types.
267 .It osx.coreFoundation.CFError
268 Check usage of CFErrorRef* parameters.
269 .It osx.coreFoundation.CFNumber
270 Check for proper uses of
272 .It osx.coreFoundation.CFRetainRelease
273 Check for null arguments to
277 .Fn CFMakeCollectable .
278 .It osx.coreFoundation.containers.OutOfBounds
279 Checks for index out-of-bounds when using the
282 .It osx.coreFoundation.containers.PointerSizedValues
288 are created with non-pointer-size values.
289 .It security.FloatLoopCounter
290 Warn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP).
291 .It security.insecureAPI.UncheckedReturn
292 Warn on uses of functions whose return values must be always checked.
293 .It security.insecureAPI.getpw
296 .It security.insecureAPI.gets
299 .It security.insecureAPI.mkstemp
302 is passed fewer than 6 X's in the format string.
303 .It security.insecureAPI.mktemp
306 .It security.insecureAPI.rand
310 and related functions.
311 .It security.insecureAPI.strcpy
316 .It security.insecureAPI.vfork
320 Check calls to various UNIX/Posix functions.
322 Check for memory leaks, double free, and use-after-free.
323 .It unix.cstring.BadSizeArg
324 Check the size argument passed into C string functions for common
326 .It unix.cstring.NullArg
327 Check for null pointers being passed as arguments to C string functions.
331 .Ic scan-build -o /tmp/myhtmldir make -j4
333 The above example causes analysis reports to be deposited into
341 A different subdirectory is created each time
344 The analyzer should support most parallel builds, but not distributed builds.
349 Documentation contributed by
350 .An "James K. Lowden" Aq jklowden@schemamania.org .