Hello,
I would like to present you a small plugin, which could be a good
exemple of a MELT use case.
This plugin allows to monitor that after every call to the fopen
function, we have a test on the pointer returned by fopen (monitoring
that it is not null).
It creates a pass after SSA and works on gimple. It firstly matchs the
gimple_call on fopen and save the tree corresponding to the FILE *. Then
we check that the next instruction is a gimple_cond between the saved
tree and the NULL ptr.
When no test are found, the following error is returned:
"test_fopen_cfile.c:35:11: warning: fopen not followed by a test on his
returned pointer [enabled by default]"
I think MELT is particulary adaptated when we have to match tree or
gimples like I do here.
For the moment I have only used it on small test file. I will try to see
what it gives on a more realistic small to medium application.
The code can be find on github: https://github.com/Piervit/GMWarn . The
idea is to add more plugins. If you have some ideas or remarks, I am
interested (however I still have to learn a lot from both GCC and MELT).
If you try the code you will need to use the GCC MELT branch (or there
is some changes to do in the Makefile to have it with MELT as plugin).
Regards!