Using scan-build with custom checker plugins

we implemented some custom clang Static Analyzer checkers for our needs and compiled them as external modules.

When calling clang directly, one can use "-Xclang" to pass the command to load and run the checkers:

clang++ -Xclang -load -Xclang ./ -Xclang -analyzer-checker=example.MainCallChecker --analyze global_static.cpp

This variant works fine.

Is there a way, to still load the custom plugins when using the scan-build tool on regular make files?

As a workaround, I implemented a new environment variable named "CCC_ANALYZER_PLUGINS" which is read by the c++-analyzer script and used to pass the plugins to load to the clang call.


Hi Thomas,

I am not aware of anyone else using scan-build with plugin checkers. I think the best way to implement this would be to add command line options to scan-build to specify the plugins and have scan-build pass those on to c+±analyzer. This is how other flags are supported, for example, see “-enable-checker”. Would be great if you submit the patch for this to the open source codebase!


Hi Anna,
thanks for clarifying this. I will prepare a patch with the functionality you proposed and submit it.