SCAN-BUILD(1)
πΈ NAME πΈ
scan-build β the Clang static analyzer. That's her. That's the whole name, periodt π
(and yeah, she lives in the General Commands Manual, section 1, iykyk)
β¨ SYNOPSIS β¨
scan-build [-ohkvV] [-analyze-headers] [-enable-checker [checker_name]]
[-disable-checker [checker_name]] [--help] [--help-checkers]
[--html-title [=title]] [--keep-going] [-plist] [-plist-html]
[--status-bugs] [--use-c++ [=compiler_path]]
[--use-cc [=compiler_path]] [--view] [-constraints [model]]
[-maxloop N] [-no-failure-reports] [-stats] [-store [model]]
build_command [build_options]
π¦ DESCRIPTION π¦
okay so scan-build is a Perl script that invokes the Clang static analyzer. That's the whole vibe. The options meant for scan-build itself (or for the analyzer) come first, and then after all of those you put your build_command plus any build_options you'd normally use to build the target system. Simple as that π«Ά
The static analyzer runs a long list of checking algorithms β go peek at CHECKERS for the whole roster. Output can be written in standard .plist format and/or HTML format, your choice bestie β¨
π the options (yes, all of them) π
The following options are supported:
-analyze-headersβ also analyze functions inside#includedfiles. yes, go deeper π-enable-checkerchecker_name,-disable-checkerchecker_name β turn checker_name on or off. See CHECKERS for the menu π-h,--helpβ display this message.--help-checkersβ list the default checkers. See CHECKERS.--html-title[=title]β specify the title used on generated HTML pages. If you don't pass title, a default title gets generated for you, no stress β¨-k,--keep-goingβ adds a βkeep on goingβ option tobuild_command. Currently supportsmakeandxcodebuild. It's a convenience option β you can absolutely just specify this behavior directly using build options if that's your thing.-oβ target directory for HTML report files. Subdirectories get created as needed to represent separate invocations of the analyzer. If you don't specify this option, a directory is created in/tmp(TMPDIRon Mac OS X) to store the reports.-plistβ output the results as a set of.plistfiles. (By default the output ofscan-buildis a set of HTML files, jsyk.)-plist-htmlβ output the results as a set of HTML and.plistfiles. both. greedy. iconic π--status-bugsβ set exit status to1if it found potential bugs and0otherwise. By default the exit status ofscan-buildis whateverbuild_commandreturned.--use-c++[=compiler_path]β guess the default compiler for your C++ and Objective-C++ code. Use this option to specify an alternate compiler.--use-cc[=compiler_path]β guess the default compiler for your C and Objective-C code. Use this option to specify an alternate compiler.-vβ verbose output fromscan-buildand the analyzer. A second and thirdvincreases verbosity. v, vv, vvv β the escalation we deserve π£οΈ-V,--viewβ view analysis results in a web browser when the build completes.-constraints [model]β specify the constraint engine used by the analyzer. By default therangemodel is used. Specifyingbasicuses a simpler, less powerful constraint model β the one used by checker-0.160 and earlier.-maxloop Nβ specify the number of times a block can be visited before giving up. Default is4. Increase it for more comprehensive coverage, at a cost of speed. (trade-offs, always trade-offs π)-no-failure-reportsβ do not create afailuressubdirectory that includes analyzer crash reports and preprocessed source files.-statsβ generates visitation statistics for the project being analyzed.-store [model]β specify the store model used by the analyzer. By default, theregionstore model is used.regionspecifies a field-sensitive store model. Users can also specifybasic, which is far less precise but can more quickly analyze code.basicwas the default store model for checker-0.221 and earlier.
π EXIT STATUS π
scan-build returns the value returned by build_command β unless --status-bugs or --keep-going is used. Then all bets are off and the rules change, so read the option list again, bestie π
π CHECKERS π
The checkers listed below may be enabled/disabled using the -enable-checker and -disable-checker options. A default group of checkers is run unless explicitly disabled. Exactly which checkers constitute the default group is a function of the operating system in use; they are listed with --help-checkers. So if you're wondering "wait, which ones are actually on right now" β that's the command, go ask her π
core.AdjustedReturnValueβ check to see if the return value of a function call is different than the caller expects (e.g., from calls through function pointers).core.AttributeNonNullβ check for null pointers passed as arguments to a function whose arguments are marked with thenonnullattribute.core.CallAndMessageβ check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers).core.DivideZeroβ check for division by zero.core.NullDereferenceβ check for dereferences of null pointers.core.StackAddressEscapeβ check that addresses to stack memory do not escape the function.core.UndefinedBinaryOperatorResultβ check for undefined results of binary operators.core.VLASizeβ check for declarations of VLA of undefined or zero size.core.builtin.BuiltinFunctionsβ evaluate compiler builtin functions, e.g.alloca().core.builtin.NoReturnFunctionsβ evaluatepanicfunctions that are known to not return to the caller.core.uninitialized.ArraySubscriptβ check for uninitialized values used as array subscripts.core.uninitialized.Assignβ check for assigning uninitialized values.core.uninitialized.Branchβ check for uninitialized values used as branch conditions.core.uninitialized.CapturedBlockVariableβ check for blocks that capture uninitialized values.core.uninitialized.UndefReturnβ check for uninitialized values being returned to the caller.deadcode.DeadStoresβ check for values stored to variables that are never read afterwards.debug.DumpCFGβ display Control-Flow Graphs.debug.DumpCallGraphβ display Call Graph.debug.DumpDominatorsβ print the dominance tree for a given Control-Flow Graph.debug.DumpLiveVarsβ print results of live variable analysis.debug.Statsβ emit warnings with analyzer statistics.debug.TaintTestβ mark tainted symbols as such.debug.ViewCFGβ view Control-Flow Graphs using GraphViz.debug.ViewCallGraphβ view Call Graph using GraphViz.llvm.Conventionsβ check code for LLVM codebase conventions.osx.APIβ check for proper uses of various Mac OS X APIs.osx.AtomicCASβ evaluate calls to OSAtomic functions.osx.SecKeychainAPIβ check for proper uses of Secure Keychain APIs.osx.cocoa.AtSyncβ check for null pointers used as mutexes for@synchronized.osx.cocoa.ClassReleaseβ check for sendingretain,release,orautoreleasedirectly to a Class.osx.cocoa.IncompatibleMethodTypesβ warn about Objective-C method signatures with type incompatibilities.osx.cocoa.NSAutoreleasePoolβ warn for suboptimal uses of NSAutoreleasePool in Objective-C GC mode.osx.cocoa.NSErrorβ check usage ofNSError**parameters.osx.cocoa.NilArgβ check for prohibited nil arguments to Objective-C method calls.osx.cocoa.RetainCountβ check for leaks and improper reference count management.osx.cocoa.SelfInitβ check thatselfis properly initialized inside an initializer method.osx.cocoa.UnusedIvarsβ warn about private ivars that are never used.osx.cocoa.VariadicMethodTypesβ check for passing non-Objective-C types to variadic methods that expect only Objective-C types.osx.coreFoundation.CFErrorβ check usage ofCFErrorRef*parameters.osx.coreFoundation.CFNumberβ check for proper uses ofCFNumberCreate().osx.coreFoundation.CFRetainReleaseβ check for null arguments toCFRetain(),CFRelease(), andCFMakeCollectable().osx.coreFoundation.containers.OutOfBoundsβ checks for index out-of-bounds when using the CFArray API.osx.coreFoundation.containers.PointerSizedValuesβ warns if CFArray, CFDictionary, or CFSet are created with non-pointer-size values.security.FloatLoopCounterβ warn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP).security.insecureAPI.UncheckedReturnβ warn on uses of functions whose return values must be always checked.security.insecureAPI.getpwβ warn on uses ofgetpw().security.insecureAPI.getsβ warn on uses ofgets().security.insecureAPI.mkstempβ warn whenmkstemp()is passed fewer than 6 X's in the format string.security.insecureAPI.mktempβ warn on uses ofmktemp().security.insecureAPI.randβ warn on uses ofrand(),random(), and related functions.security.insecureAPI.strcpyβ warn on uses ofstrcpy()andstrcat().security.insecureAPI.vforkβ warn on uses ofvfork().unix.APIβ check calls to various UNIX/Posix functions.unix.Mallocβ check for memory leaks, double free, and use-after-free.unix.cstring.BadSizeArgβ check the size argument passed into C string functions for common erroneous patterns.unix.cstring.NullArgβ check for null pointers being passed as arguments to C string functions.
π EXAMPLE π
scan-build -o /tmp/myhtmldir make -j4
The above example causes analysis reports to be deposited into a subdirectory of /tmp/myhtmldir and to run make with the -j4 option. A different subdirectory is created each time scan-build analyzes a project. The analyzer should support most parallel builds, but not distributed builds.
ok real talk: parallel builds? mostly yes bestie π«Ά. distributed builds? absolutely not, don't even try it π
π AUTHORS π
scan-build was written by Ted Kremenek. Documentation contributed by James K. Lowden <jklowden@schemamania.org>.
and that's the whole page, bestie π this was clang 20, dated Aug 18, 2024, and it's the SCAN-BUILD(1) page β go analyze something and make it slay β¨π¦π
π¦ where this page comes from
- epel 10: clang20-analyzer 20.1.8-9.el10_3 Β· Apache-2.0 WITH LLVM-exception OR NCSA OR MIT
- epel 9: clang20-analyzer 20.1.8-9.el9 Β· Apache-2.0 WITH LLVM-exception OR NCSA OR MIT
- fedora 43: clang20-analyzer 20.1.8-2.fc43 Β· Apache-2.0 WITH LLVM-exception OR NCSA OR MIT
- fedora 44: clang20-analyzer 20.1.8-2.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA OR MIT
- fedora 44: clang20-analyzer 20.1.8-9.fc44 Β· Apache-2.0 WITH LLVM-exception OR NCSA OR MIT
- ubuntu noble: clang-tools-20 1:20.1.2-0ubuntu1~24.04.3 Β· APACHE-2-LLVM-EXCEPTIONS
- ubuntu questing: clang-tools-20 1:20.1.8-0ubuntu4
- ubuntu resolute: clang-tools-20 1:20.1.8-2ubuntu8 Β· APACHE-2-LLVM-EXCEPTIONS
- ubuntu stonking: clang-tools-20 1:20.1.8-2ubuntu13 Β· APACHE-2-LLVM-EXCEPTIONS
- π the page's license: Apache-2.0 WITH LLVM-exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms