[cfe-dev] Clang: checker vs. plugin

Jordan Rose jordan_rose at apple.com
Thu Apr 24 10:09:15 PDT 2014


That's not quite the distinction, but it's probably close enough for your purposes.

In Clang, "plugin" means a shared library (DLL, .so, .dylib) that can be loaded by the compiler. The most common use of plugins is to provide additional "actions" to perform on an AST after it has been parsed; the '-plugin' flag is used to select which plugin actions to run. See http://clang.llvm.org/docs/ClangPlugins.html and the PrintFunctionNames plugin in the examples/ directory.

A "checker" is used by the analyzer to improve knowledge about the program it's analyzing; it's a sort of visitor that can get callbacks for each expression that gets evaluated. The analyzer has a number of built-in checkers, just like the compiler has several built-in AST actions. Plugins (i.e. loaded libraries) can also add additional checkers, though support for this is a bit brittle.* The only real documentation on this is in include/clang/StaticAnalyzer/Core/CheckerRegistry.h, plus the tiny checker plugin in the examples/ directory.

Hope that helps clear things up a bit.
Jordan

* I was the one who added support for checker plugins many years ago (before joining Apple), but no one's really taken ownership in the past few years. We're pretty much just keeping the existing support limping along, no improvements.


On Apr 21, 2014, at 4:53 , Aitor San Juan <aitor.sj at opendeusto.es> wrote:

> Reading the docs through carefully, I have realized that plugins are used by the compiler, whereas checkers are used by the analyzer. Sorry for such a trivial question.
> Cheers.
> 
> 2014-04-19 13:43 GMT+02:00 Aitor San Juan <aitor.sj at opendeusto.es>:
> Hello,
> 
> I was wondering the difference between the concept of a plugin and a checker. Please, correct me. As far as I know, from a technical point of view, a plugin is a separately compiled routine (DLL) that may be loaded by the compiler (compile-time). However, a checker is a routine used by Clang's analyzer to enhance the latter's analysis logic (in the case of  a checker, in order for the analyzer to be able to use it, the latter must be rebuilt).
> 
> I also wonder whether a plugin can also interact with Clang's analyzer? If so, then what reason could make you decide whether to implement a checker or a plugin?
> 
> Thanks.
> Aitor.
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140424/1b60b2b9/attachment.html>


More information about the cfe-dev mailing list