Skip to content

Integrate Clang Static Analyzer with flycheck for on-the-fly static analysis in Emacs

Notifications You must be signed in to change notification settings

alexmurray/flycheck-clang-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flycheck Clang Static Analyzer (scan-build) Checker

License GPL 3 MELPA Build Status

Integrate Clang Static Analyzer (aka. scan-build) with flycheck to automatically perform on-the-fly static analysis as you code.

flycheck-clang-analyzer screenshot

This package leverages the configuration of the existing c/c++-clang flycheck checker, or either emacs-cquery, emacs-ccls, irony-mode or rtags to provide the appropriate compiler flags for clang - and so requires zero extra setup. This checker also automatically chains itself as the next flycheck checker after c/c++-clang, lsp-ui flycheck-irony and flycheck-rtags so that it only runs when the corresponding previous checker returns without warnings. This avoids trying to perform the analysis when there are syntactic errors etc.

Installation

MELPA

The preferred way to install flycheck-clang-analyzer is via MELPA - then you can just M-x package-install RET flycheck-clang-analyzer RET

To enable then simply add the following to your init file:

(with-eval-after-load 'flycheck
  (require 'flycheck-clang-analyzer)
  (flycheck-clang-analyzer-setup))

We recommend to use use-package to make this automatic:

(use-package flycheck-clang-analyzer
  :ensure t
  :after flycheck
  :config (flycheck-clang-analyzer-setup))

Manual

If you would like to install the package manually, download or clone it and place it within Emacs' load-path, then you can require it in your init file like this:

(require 'flycheck-clang-analyzer)
(flycheck-clang-analyzer-setup)

NOTE: This will also require the manual installation of flycheck if you have not done so already.

Configuration

This should work with zero configuration, since we try and leverage the configuration of existing clang-based Flycheck checkers.

The only configuration option is flycheck-clang-analyzer-executable which is the path to the clang executable - this defaults to clang. However if you need to change this to something else, simply setq it as appropriate before calling (flycheck-clang-analyzer-setup) - so to set to use clang-3.8 instead of clang:

(setq flycheck-clang-analyzer-executable "clang-3.8")
(flycheck-clang-analyzer-setup)

License

Copyright © 2018 Alex Murray

Distributed under GNU GPL, version 3.

About

Integrate Clang Static Analyzer with flycheck for on-the-fly static analysis in Emacs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published