Can I write a standalone static analyzer?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
Clang static analyzer is a great tool, but its checkers are only for general purpose. I want write some customized checkers. As I know, static analyzer is a port of clang, clang-tidy maybe a good choice, but it does not support path sensitive checker. It seems that I must modify clang source code? Can I write a standalone static analyzer which built on static analyzer module, but also support path sensitive checking?

Thanks,
meritozh

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
Hi meritozh!

CSA supports and encourage you to write custom opt-in checkers. Please explain what does mean "general purpose" statement and in which context you have to implement a new tool?

Thanks, Alexey K

2017-12-12 9:33 GMT+03:00 gao ge via cfe-dev <[hidden email]>:
Clang static analyzer is a great tool, but its checkers are only for general purpose. I want write some customized checkers. As I know, static analyzer is a port of clang, clang-tidy maybe a good choice, but it does not support path sensitive checker. It seems that I must modify clang source code? Can I write a standalone static analyzer which built on static analyzer module, but also support path sensitive checking?

Thanks,
meritozh

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




--

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
To further answer the question - I think meritozh may be saying "I wish I could write checkers without modifying the clang source code" to which the response is "you can!" You can compile your checker as a clang plugin to a shared object file and then load that plugin. That way there's no need to recompile clang, but you are still able to write your own custom checkers.

You need to implement the clang_registerCheckers function in your plugin. See here: https://clang.llvm.org/doxygen/CheckerRegistry_8h_source.html

Does that answer your question?
-- Matthew P. Del Buono

On Mon, Dec 11, 2017 at 11:27 PM, Alexey Knyshev via cfe-dev <[hidden email]> wrote:
Hi meritozh!

CSA supports and encourage you to write custom opt-in checkers. Please explain what does mean "general purpose" statement and in which context you have to implement a new tool?

Thanks, Alexey K

2017-12-12 9:33 GMT+03:00 gao ge via cfe-dev <[hidden email]>:
Clang static analyzer is a great tool, but its checkers are only for general purpose. I want write some customized checkers. As I know, static analyzer is a port of clang, clang-tidy maybe a good choice, but it does not support path sensitive checker. It seems that I must modify clang source code? Can I write a standalone static analyzer which built on static analyzer module, but also support path sensitive checking?

Thanks,
meritozh

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




--

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
Hi, thank you for your responses.

For Alexey, I have one method which can only be called in several special methods. Or one property, it must have a rvalue in any path, Thera are not general, I must do it by myself.

For Matthew, Clang Plugin is a better choice against modifying clang source code directly, but a plugin must be compatible with clang libraries in ABI level. Clang is a modern and modular project, so my question is, can I only link with several clang libraries, produce one tool which can do static analyze just like tools in clang-tools-extra? But it can also support path sensitive checking.

By the way, why clang-tidy can not support invoke path sensitive checkers?

P.S.: English is not my mother language, sorry for my poor English : (

On Tue, Dec 12, 2017 at 5:49 PM Matthew Del Buono <[hidden email]> wrote:
To further answer the question - I think meritozh may be saying "I wish I could write checkers without modifying the clang source code" to which the response is "you can!" You can compile your checker as a clang plugin to a shared object file and then load that plugin. That way there's no need to recompile clang, but you are still able to write your own custom checkers.

You need to implement the clang_registerCheckers function in your plugin. See here: https://clang.llvm.org/doxygen/CheckerRegistry_8h_source.html

Does that answer your question?
-- Matthew P. Del Buono

On Mon, Dec 11, 2017 at 11:27 PM, Alexey Knyshev via cfe-dev <[hidden email]> wrote:
Hi meritozh!

CSA supports and encourage you to write custom opt-in checkers. Please explain what does mean "general purpose" statement and in which context you have to implement a new tool?

Thanks, Alexey K

2017-12-12 9:33 GMT+03:00 gao ge via cfe-dev <[hidden email]>:
Clang static analyzer is a great tool, but its checkers are only for general purpose. I want write some customized checkers. As I know, static analyzer is a port of clang, clang-tidy maybe a good choice, but it does not support path sensitive checker. It seems that I must modify clang source code? Can I write a standalone static analyzer which built on static analyzer module, but also support path sensitive checking?

Thanks,
meritozh

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




--

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
Have you looked at clazy (https://github.com/KDE/clazy)? If it doesn't already
do what you want it might well show you how to do it yourself.

R.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
Though clazy doesn't not support path sensitive checker, it is a great entry point for me to write a standalone tool for me. Thank you, Rene. 

On Thu, Dec 14, 2017 at 6:13 PM René J. V. Bertin via cfe-dev <[hidden email]> wrote:
Have you looked at clazy (https://github.com/KDE/clazy)? If it doesn't already
do what you want it might well show you how to do it yourself.

R.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
In reply to this post by Eric Fiselier via cfe-dev
I think what Matthew proposed is the best way to go. You can see
examples/analyzer-plugin in clang source tree - it compiles to a clang
plugin that you can load into existing clang binary in run-time with a
flag, and you can write your domain-specific checkers this way without
modifying clang directly.

If you explicitly want a standalone tool like clang-tidy, then note that
clang-tidy itself can run static analyzer checkers as well, including
path-sensitive checkers as well. What i don't know, however, is whether
you can load clang plugins from clang-tidy.

On 12/12/2017 1:49 AM, Matthew Del Buono via cfe-dev wrote:

> To further answer the question - I think meritozh may be saying "I
> wish I could write checkers without modifying the clang source code"
> to which the response is "you can!" You can compile your checker as a
> clang plugin to a shared object file and then load that plugin. That
> way there's no need to recompile clang, but you are still able to
> write your own custom checkers.
>
> You need to implement the clang_registerCheckers function in your
> plugin. See here:
> https://clang.llvm.org/doxygen/CheckerRegistry_8h_source.html
>
> Does that answer your question?
> -- Matthew P. Del Buono
>
> On Mon, Dec 11, 2017 at 11:27 PM, Alexey Knyshev via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi meritozh!
>
>     CSA supports and encourage you to write custom opt-in checkers.
>     Please explain what does mean "general purpose" statement and in
>     which context you have to implement a new tool?
>
>     Thanks, Alexey K
>
>     2017-12-12 9:33 GMT+03:00 gao ge via cfe-dev
>     <[hidden email] <mailto:[hidden email]>>:
>
>         Clang static analyzer is a great tool, but its checkers are
>         only for general purpose. I want write some customized
>         checkers. As I know, static analyzer is a port of clang,
>         clang-tidy maybe a good choice, but it does not support path
>         sensitive checker. It seems that I must modify clang source
>         code? Can I write a standalone static analyzer which built on
>         static analyzer module, but also support path sensitive checking?
>
>         Thanks,
>         meritozh
>
>         _______________________________________________
>         cfe-dev mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>         <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
>
>
>
>     --
>     linkedin.com/profile
>     <https://www.linkedin.com/profile/view?id=AAMAABn6oKQBDhBteiQnWsYm-S9yxT7wQkfWhSw>
>
>     github.com/alexeyknyshev <http://github.com/alexeyknyshev>
>     bitbucket.org/alexeyknyshev <https://bitbucket.org/alexeyknyshev/>
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can I write a standalone static analyzer?

Eric Fiselier via cfe-dev
No, clang-tidy can not load clang plugin right now, but there is a tracking issue, https://bugs.llvm.org//show_bug.cgi?id=32739.
Finally, after trade-off, writing checker as plugin is the best way for me.

Thank you very much.

On Fri, Dec 15, 2017 at 3:15 AM Artem Dergachev via cfe-dev <[hidden email]> wrote:
I think what Matthew proposed is the best way to go. You can see
examples/analyzer-plugin in clang source tree - it compiles to a clang
plugin that you can load into existing clang binary in run-time with a
flag, and you can write your domain-specific checkers this way without
modifying clang directly.

If you explicitly want a standalone tool like clang-tidy, then note that
clang-tidy itself can run static analyzer checkers as well, including
path-sensitive checkers as well. What i don't know, however, is whether
you can load clang plugins from clang-tidy.

On 12/12/2017 1:49 AM, Matthew Del Buono via cfe-dev wrote:
> To further answer the question - I think meritozh may be saying "I
> wish I could write checkers without modifying the clang source code"
> to which the response is "you can!" You can compile your checker as a
> clang plugin to a shared object file and then load that plugin. That
> way there's no need to recompile clang, but you are still able to
> write your own custom checkers.
>
> You need to implement the clang_registerCheckers function in your
> plugin. See here:
> https://clang.llvm.org/doxygen/CheckerRegistry_8h_source.html
>
> Does that answer your question?
> -- Matthew P. Del Buono
>
> On Mon, Dec 11, 2017 at 11:27 PM, Alexey Knyshev via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi meritozh!
>
>     CSA supports and encourage you to write custom opt-in checkers.
>     Please explain what does mean "general purpose" statement and in
>     which context you have to implement a new tool?
>
>     Thanks, Alexey K
>
>     2017-12-12 9:33 GMT+03:00 gao ge via cfe-dev
>     <[hidden email] <mailto:[hidden email]>>:
>
>         Clang static analyzer is a great tool, but its checkers are
>         only for general purpose. I want write some customized
>         checkers. As I know, static analyzer is a port of clang,
>         clang-tidy maybe a good choice, but it does not support path
>         sensitive checker. It seems that I must modify clang source
>         code? Can I write a standalone static analyzer which built on
>         static analyzer module, but also support path sensitive checking?
>
>         Thanks,
>         meritozh
>
>         _______________________________________________
>         cfe-dev mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>         <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
>
>
>
>     --
>     linkedin.com/profile
>     <https://www.linkedin.com/profile/view?id=AAMAABn6oKQBDhBteiQnWsYm-S9yxT7wQkfWhSw>
>
>     github.com/alexeyknyshev <http://github.com/alexeyknyshev>
>     bitbucket.org/alexeyknyshev <https://bitbucket.org/alexeyknyshev/>
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev