[cfe-dev] [RFC PATCH] making the static analyzer a PluginASTAction

nobled nobled at dreamwidth.org
Sun Dec 18 03:38:27 PST 2011


> Not sure how to post large changes; I squashed the changes into a
> single patch attached here. Most of its size is from updating
> test/Analysis/. I was working on it as a series of ten patches though,
> if anyone wants a git branch for easier review.
>
> This change mostly moves the option parsing code out of libFrontend
> into libStaticAnalyzer. It can't compiler the analyzer as a separate
> loadable module, yet.
>
> Ultimately, this could remove the dependencies that libFrontendTool
> has on all the static analyzer libraries, but can't quite yet because
> the final change I tried to make (removing the RunAnalysis enum and
> the related code) mysteriously caused "unable to find plugin
> 'analyzer'" regressions, so I left that change out.
>
> Also allll the tests were updated from using `clang -cc1 -analyze` to
> using `clang -cc1 -plugin analyzer`, with some copious
> -plugin-arg-analyzer sprinkled in between to pass the arguments to the
> plugin layer.
>
> Somehow, this change exposed a problem in lib/Driver/Tools.cpp, which
> was by default adding "-static-analyzer-checker=security" to the
> analyzer. I'm not sure how it ever worked before, because after this
> change I got the error "no analyzer checkers are associated with
> 'security'", which was true; changing it to "experimental.security"
> fixed it.
>
> There is a small hack in InitPreprocessor.cpp now, though, since I'm
> not sure how to add a predefined macro ("__clang_analyzer__") from a
> PluginASTAction.

This seems to be stuck in the moderation queue, which is just as well,
since the patch had some problems that I fixed now.

The current changes are in this git branch:
https://github.com/nobled/clang/tree/anal-plugin



More information about the cfe-dev mailing list