Blame | Last modification | View Log | Download | RSS feed
.\" Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions..\" See https://llvm.org/LICENSE.txt for license information..\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.\" $Id$.Dd Aug 1, 2022.Dt SCAN-BUILD 1.Os "clang" "16".Sh NAME.Nm scan-build.Nd Clang static analyzer.Sh SYNOPSIS.Nm.Op Fl ohkvV.Op Fl analyze-headers.Op Fl enable-checker Op Ar checker_name.Op Fl disable-checker Op Ar checker_name.Op Fl Fl help.Op Fl Fl help-checkers.Op Fl Fl html-title Op Ar =title.Op Fl Fl keep-going.Op Fl plist.Op Fl plist-html.Op Fl Fl status-bugs.Op Fl Fl use-c++ Op Ar =compiler_path.Op Fl Fl use-cc Op Ar =compiler_path.Op Fl Fl view.Op Fl constraints Op Ar model.Op Fl maxloop Ar N.Op Fl no-failure-reports.Op Fl stats.Op Fl store Op Ar model.Ar build_command.Op build_options.\".\" Sh DESCRIPTION.Sh DESCRIPTION.Nmis a Perl script that invokes the Clang static analyzer. Options used by.Nmor by the analyzer appear first, followed by the.Ar build_commandand any.Ar build_optionsnormally used to build the target system..PpThe static analyzer employs a long list of checking algorithms, see.Sx CHECKERS .Output can be written in standard.Li .plistand/or HTML format..PpThe following options are supported:.Bl -tag -width indent.It Fl analyze-headersAlso analyze functions in #included files..It Fl enable-checker Ar checker_name , Fl disable-checker Ar checker_nameEnable/disable.Ar checker_name .See.Sx CHECKERS ..It Fl h , Fl Fl helpDisplay this message..It Fl Fl help-checkersList default checkers, see.Sx CHECKERS ..It Fl Fl html-title Ns Op = Ns Ar titleSpecify the title used on generated HTML pages.A default title is generated if.Ar titleis not specified..It Fl k , Fl Fl keep-goingAdd a.Dq keep on goingoption to.Ar build_command .Currently supports make and xcodebuild. This is a convenience option;one can specify this behavior directly using build options..It Fl oTarget directory for HTML report files. Subdirectories will becreated as needed to represent separate invocationsof the analyzer. If this option is not specified, a directory iscreated in /tmp (TMPDIR on Mac OS X) to store the reports..It Fl plistOutput the results as a set of.Li .plistfiles. (By default the output of.Nmis a set of HTML files.).It Fl plist-htmlOutput the results as a set of HTML and .plist files.It Fl Fl status-bugsSet exit status to 1 if it found potential bugs and 0 otherwise. Bydefault the exit status of.Nmis that returned by.Ar build_command ..It Fl Fl use-c++ Ns Op = Ns Ar compiler_pathGuess the default compiler for your C++ and Objective-C++ code. Use thisoption to specify an alternate compiler..It Fl Fl use-cc Ns Op = Ns Ar compiler_pathGuess the default compiler for your C and Objective-C code. Use thisoption to specify an alternate compiler..It Fl vVerbose output from.Nmand the analyzer. A second andthird.Ar vincreases verbosity..It Fl V , Fl Fl viewView analysis results in a web browser when the build completes..It Fl constraints Op Ar modelSpecify the constraint engine used by the analyzer. By default the.Ql rangemodel is used. Specifying.Ql basicuses a simpler, less powerful constraint model used by checker-0.160and earlier..It Fl maxloop Ar NSpecify the number of times a block can be visited before givingup. Default is 4. Increase for more comprehensive coverage at acost of speed..It Fl no-failure-reportsDo not create a.Ql failuressubdirectory that includes analyzer crash reports and preprocessedsource files..It Fl statsGenerates visitation statistics for the project being analyzed..It Fl store Op Ar modelSpecify the store model used by the analyzer. By default, the.Ql regionstore model is used..Ql regionspecifies a field-sensitive store model. Users can also specify.Ql basicwhich is far less precise but can more quickly analyze code..Ql basicwas the default store model for checker-0.221 and earlier..\".El.Sh EXIT STATUS.Nmreturns the value returned by.Ar build_commandunless.Fl Fl status-bugsor.Fl Fl keep-goingis used..\".\" Other sections not yet used ....\" .Sh ENVIRONMENT.\" .Sh FILES.\" .Sh DIAGNOSTICS.\" .Sh COMPATIBILITY.\" .Sh HISTORY.\" .Sh BUGS.\".Sh CHECKERSThe checkers listed below may be enabled/disabled using the.Fl enable-checkerand.Fl disable-checkeroptions.A default group of checkers is run unless explicitly disabled.Exactly which checkers constitute the default group is a functionof the operating system in use; they are listed with.Fl Fl help-checkers ..Bl -tag -width indent..It core.AdjustedReturnValueCheck to see if the return value of a function call is different thanthe caller expects (e.g., from calls through function pointers)..It core.AttributeNonNullCheck for null pointers passed as arguments to a function whose arguments are marked with the.Ql nonnullattribute..It core.CallAndMessageCheck for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers)..It core.DivideZeroCheck for division by zero..It core.NullDereferenceCheck for dereferences of null pointers..It core.StackAddressEscapeCheck that addresses to stack memory do not escape the function..It core.UndefinedBinaryOperatorResultCheck for undefined results of binary operators..It core.VLASizeCheck for declarations of VLA of undefined or zero size..It core.builtin.BuiltinFunctionsEvaluate compiler builtin functions, e.g..Fn alloca ..It core.builtin.NoReturnFunctionsEvaluate.Ql panicfunctions that are known to not return to the caller..It core.uninitialized.ArraySubscriptCheck for uninitialized values used as array subscripts..It core.uninitialized.AssignCheck for assigning uninitialized values..It core.uninitialized.BranchCheck for uninitialized values used as branch conditions..It core.uninitialized.CapturedBlockVariableCheck for blocks that capture uninitialized values..It core.uninitialized.UndefReturnCheck for uninitialized values being returned to the caller..It deadcode.DeadStoresCheck for values stored to variables that are never read afterwards..It debug.DumpCFGDisplay Control-Flow Graphs..It debug.DumpCallGraphDisplay Call Graph..It debug.DumpDominatorsPrint the dominance tree for a given Control-Flow Graph..It debug.DumpLiveVarsPrint results of live variable analysis..It debug.StatsEmit warnings with analyzer statistics..It debug.TaintTestMark tainted symbols as such..It debug.ViewCFGView Control-Flow Graphs using.Ic GraphViz ..It debug.ViewCallGraphView Call Graph using.Ic GraphViz ..It llvm.ConventionsCheck code for LLVM codebase conventions..It osx.APICheck for proper uses of various Mac OS X APIs..It osx.AtomicCASEvaluate calls to.Vt OSAtomicfunctions..It osx.SecKeychainAPICheck for proper uses of Secure Keychain APIs..It osx.cocoa.AtSyncCheck for null pointers used as mutexes for @synchronized..It osx.cocoa.ClassReleaseCheck for sending.Ql retain ,.Ql release,or.Ql autoreleasedirectly to a Class..It osx.cocoa.IncompatibleMethodTypesWarn about Objective-C method signatures with type incompatibilities..It osx.cocoa.NSAutoreleasePoolWarn for suboptimal uses of.Vt NSAutoreleasePoolin Objective-C GC mode..It osx.cocoa.NSErrorCheck usage of NSError** parameters..It osx.cocoa.NilArgCheck for prohibited nil arguments to Objective-C method calls..It osx.cocoa.RetainCountCheck for leaks and improper reference count management..It osx.cocoa.SelfInitCheck that.Ql selfis properly initialized inside an initializer method..It osx.cocoa.UnusedIvarsWarn about private ivars that are never used..It osx.cocoa.VariadicMethodTypesCheck for passing non-Objective-C types to variadic methods that expect only Objective-C types..It osx.coreFoundation.CFErrorCheck usage of CFErrorRef* parameters..It osx.coreFoundation.CFNumberCheck for proper uses of.Fn CFNumberCreate ..It osx.coreFoundation.CFRetainReleaseCheck for null arguments to.Fn CFRetain ,.Fn CFRelease ,and.Fn CFMakeCollectable ..It osx.coreFoundation.containers.OutOfBoundsChecks for index out-of-bounds when using the.Vt CFArrayAPI..It osx.coreFoundation.containers.PointerSizedValuesWarns if.Vt CFArray ,.Vt CFDictionary ,or.Vt CFSetare created with non-pointer-size values..It security.FloatLoopCounterWarn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP)..It security.insecureAPI.UncheckedReturnWarn on uses of functions whose return values must be always checked..It security.insecureAPI.getpwWarn on uses of.Fn getpw ..It security.insecureAPI.getsWarn on uses of.Fn gets ..It security.insecureAPI.mkstempWarn when.Fn mkstempis passed fewer than 6 X's in the format string..It security.insecureAPI.mktempWarn on uses of.Fn mktemp ..It security.insecureAPI.randWarn on uses of.Fn rand ,.Fn random ,and related functions..It security.insecureAPI.strcpyWarn on uses of.Fn strcpyand.Fn strcat ..It security.insecureAPI.vforkWarn on uses of.Fn vfork ..It unix.APICheck calls to various UNIX/Posix functions..It unix.MallocCheck for memory leaks, double free, and use-after-free..It unix.cstring.BadSizeArgCheck the size argument passed into C string functions for commonerroneous patterns..It unix.cstring.NullArgCheck for null pointers being passed as arguments to C string functions..El.\".Sh EXAMPLE.Ic scan-build -o /tmp/myhtmldir make -j4.PpThe above example causes analysis reports to be deposited intoa subdirectory of.Pa /tmp/myhtmldirand to run.Ic makewith the.Fl j4option.A different subdirectory is created each time.Nmanalyzes a project.The analyzer should support most parallel builds, but not distributed builds..Sh AUTHORS.Nmwas written by.An "Ted Kremenek" .Documentation contributed by.An "James K. Lowden" Aq jklowden@schemamania.org .