This Page Is Under Construction

Checker Developer Manual

The static analyzer engine performs symbolic execution of the program and relies on a set of checkers to implement the logic for detecting and constructing bug reports. This page provides hints and guidelines for anyone who is interested in implementing their own checker. The static analyzer is a part of the Clang project, so consult Hacking on Clang and LLVM Programmer's Manual for general developer guidelines and information.

Getting Started

Static Analyzer Overview

ExplidedGraph, ExplodedNode (ProgramPoint, State)
Engine-Checker Interaction
Symbols

Idea for a Checker

Here are several questions which you should consider when evaluating your checker idea:

Checker Skeleton

The source code for all the checkers goes into clang/lib/StaticAnalyzer/Checkers.

There are two main decisions you need to make:

Describe the registration process.

Bug Reports

AST Visitors

Some checks might not require path-sensitivity to be effective. Simple AST walk might be sufficient. If that is the case, consider implementing a Clang compiler warning. On the other hand, a check might not be acceptable as a compiler warning; for example, because of a relatively high false positive rate. In this situation, AST callbacks checkASTDecl and checkASTCodeBody are your best friends.

Testing

Every patch should be well tested with Clang regression tests. The checker tests live in clang/test/Analysis folder. To run all of the analyzer tests, execute the following from the clang build directory:
    $ TESTDIRS=Analysis make test
    

Useful Commands/Debugging Hints