[cfe-users] Using Clang static analysis plugins with Clang-tidy

Orbán György via cfe-users cfe-users at lists.llvm.org
Mon Feb 22 03:08:08 PST 2016


As far as I know Clang-tidy currently does not support loading
checkers from a shared library.
I do not know why the patch was abandoned.

We are developing a tool CodeChecker
(https://github.com/Ericsson/codechecker) which can run multiple
static analyzers. Currently it supports Clang Static Analyzer and
Checkers from shared libraries built for Clang Static Analyzer can be
automatically loaded. (If you build the CodeChecker package and put
the shared library into the plugin directory)

You can analyze your project by running:
CodeChecker check -b "make clean && make"

A more detailed user guide can be found here:

Best regards,

Is it currently possible to use Clang static analysis plugins and
dynamically loaded checkers with Clang-tidy? I'm attempting to setup a
build system for a new project that will run the Clang-tidy checkers,
the static analysis checkers, and one or more custom checkers all at
once (for example the custom checker described at
https://www.kdab.com/use-static-analysis-improve-performance). Running
additional clang tools, like modernize, would also be helpful. I found
a thread on Phabricator that seems relevant
(http://reviews.llvm.org/D9555#3f7f951f), but I couldn't tell if the
patches and changes discussed ever made it into a released version of

I'm currently using the pre-compiled 3.7.0 version included in Ubuntu
15.10. However, I have no problem updating or compiling from source as
long as the required features are integrated within the next stable

Ideally, I would be able to write a simple script similar to the
pseudo-code below. While it wouldn't be my first choice, I'm willing
to write a small utility to accomplish this goal if dynamically
loading plugins is only possible when directly using one or more Clang
shared libraries. Lastly, right now, I'm not looking to modify Clang
source or directly integrate new checkers into the Clang source.

make clean
bear make
for_each(source in SOURCES){
   clang-tidy -load-plugins "MyPlugin.so MyOtherPlugin.so"
-Checkers="...." ${source}

On a slightly different note, is it possible to use clang-tidy in a
similar manner to scan-build, where you can process all source files
with a single simple command (e.g., scan-build make).

Thank you,
Sanford Freedman
cfe-users mailing list
cfe-users at lists.llvm.org

More information about the cfe-users mailing list