Skip to content

CodeChecker is a defect database and viewer extension for Clang Static Analyzer

License

Notifications You must be signed in to change notification settings

Locutus18/codechecker

Repository files navigation

Build Status

Introduction

CodeChecker is a static analysis infrastructure built on Clang Static Analyzer.

CodeChecker replaces scan-build in Clang Static Analyzer in Linux systems.

Main features:

  • store the result of multiple large analysis run results efficiently
  • run multiple analyzers, currently Clang Static Analyzer and Clang-Tidy is supported
  • dynamic web based defect viewer
  • a PostgreSQL/SQLite based defect storage & management (both are optional, results can be shown on standard output in quickcheck mode)
  • update analyzer results only for modified files (depends on the build system)
  • compare analysis results (new/resolved/unresolved bugs compared to a baseline)
  • filter analysis results (checker name, severity, source file name ...)
  • skip analysis in specific source directories if required
  • suppression of false positives (in config file or in the source)
  • Thrift API based server-client model for storing bugs and viewing results.
  • It is possible to connect multiple bug viewers. Currently a web-based viewer and a command line viewer are provided.

You can find a high level overview about the infrastructure in the presentation at the 2015 Euro LLVM Conference:

Industrial Experiences with the Clang Static Analysis Toolset
Daniel Krupp, Gyorgy Orban, Gabor Horvath and Bence Babati
( Slides)

Important Limitations

CodeChecker requires some new features from clang to work properly. If your clang version does not have these features you will see in debug log the following messages:

  • Check name wasn't found in the plist file. --> use clang = 3.7 or trunk@r228624; otherwise CodeChecker makes a guess based on the report message
  • Hash value wasn't found in the plist file. --> update for a newer clang version; otherwise CodeChecker generates a simple hash based on the filename and the line content, this method is applied for Clang Tidy results too, because Clang Tidy does not support bug identifier hash generation currently

Linux

For a more detailed dependency list see Requirements

Basic dependecy install & setup

Tested on Ubuntu LTS 14.04.2


# get ubuntu packages
# clang-3.6 can be replaced by any later versions of clang
sudo apt-get install clang-3.6 doxygen build-essential thrift-compiler python-virtualenv gcc-multilib git wget

# create new python virtualenv
virtualenv -p /usr/bin/python2.7 ~/checker_env
# activate virtualenv
source ~/checker_env/bin/activate

# get source code
git clone https://github.com/Ericsson/codechecker.git
cd codechecker

# install required basic python modules
pip install -r .ci/basic_python_requirements

# create codechecker package
./build_package.py -o ~/codechecker_package
cd ..

Check a test project

Check if clang or clang tidy is available

which clang
which clang-tidy

If 'clang' or 'clang-tidy' commands are not available the package can be configured to use another/newer clang binary for the analisys.
Edit the 'CodeChecker/config/package_layout.json' config files "runtime/analyzers" section in the generated package and modify the analyzers section to the analyzers available in the PATH

"analyzers" : {
  "clangsa" : "clang-3.6",
  "clang-tidy" : "clang-tidy-3.6"
  },

Activate virtualenv

source ~/checker_env/bin/activate

Add package bin directory to PATH.

This step can be skipped if you always give the path of CodeChecker command.

export PATH=~/codechecker_package/CodeChecker/bin:$PATH

Check the project

Check the project using SQLite. The database is placed in the working directory which can be provided by -w flag (~/.codechecker by default).

CodeChecker check -n test_project_check -b "cd my_test_project && make clean && make"

Start web server to view the results

CodeChecker server

View the results with firefox

firefox http://localhost:8001

If all goes well you can check analysis results in your web browser:

CodeChecker Viewer

See user guide for further configuration and check options.

Additional documentations

User guide

Use with PostgreSQL database

Command line usage_examples

Checker documentation

Architecture overview

Requirements

Package layout

Thrift api

External source dependencies

Test documentation

Database schema migration

About

CodeChecker is a defect database and viewer extension for Clang Static Analyzer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 79.4%
  • JavaScript 8.5%
  • C 5.8%
  • Thrift 2.6%
  • Objective-C 1.5%
  • C++ 0.8%
  • Other 1.4%