[cfe-dev] Clang: checker vs. plugin

Aitor San Juan aitor.sj at opendeusto.es
Fri Apr 25 05:44:17 PDT 2014


Many thanks for the details, Jordan.

Now new questions arise:

1)From your comments, may I conclude that checker-plugins are not in the
current development path for Clang/Analyzer? Is that path currently somehow
frozen?

2) What additional "actions" could be perfomed on an AST? I can only think
of programatically modifying the AST, i.e., programatically changing the
source code to make it, for example, compliant with coding rules or the
like. Any other uses? I'm still (in the process of) becoming more familiar
with this.

3) You say that plugins can also add additional checkers. From the example
you mention (MainCallChecker.cpp) and from the documentation in
CheckerRegistry.h, what do you exactly mean by "add"? Are you referring to
the fact that you register the checker? Am I right if I conclude that if a
plugin adds several checkers, these are packed/compiled in the same final
DLL for the plugin, and, thus, that's why the plugin needs loading to be
able to use its checkers? (in this last case, would it be necessary to
rebuild Clang as with a normal checker? I guess it wouldn't).

Thanks a lot for your reply.
Aitor.


2014-04-24 19:09 GMT+02:00 Jordan Rose <jordan_rose at apple.com>:

> 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/20140425/2902cea6/attachment.html>


More information about the cfe-dev mailing list