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

nobled nobled at dreamwidth.org
Fri Dec 16 14:06:30 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-StaticAnalyzer-factor-into-an-AST-plugin.patch
Type: text/x-patch
Size: 177634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111216/60f8dc8a/attachment.bin>


More information about the cfe-dev mailing list