Converting a Clang tool that uses Libooling to a Clang plugin

Hi Guys,

I have written a tool that uses Clang Libtooling, and performs some
instrumentation on the source code. It basically inspects all the
global defs in the AST and inserts the instrumentation code. The
original source files are over-written with the help of 'Rewriter'
class.

The tool reads the list of functions to instrument from an input file,
and also generates a couple of header files with the required
definitions for the instrumentation calls. It opens two o/p file
streams to write to the header files.

I wish to convert this tool to a Clang plugin so that I can use
command line options during the build process. This way, I won't have
to run the tool separately before building.

Can someone please let me know how easy/difficult is it going to be? I
hope that it is possible.

Thanks and regards,
Sandeep.

Can someone please provide some inputs?

Thanks,
Sandeep.

Hi Guys,

I have written a tool that uses Clang Libtooling, and performs some
instrumentation on the source code. It basically inspects all the
global defs in the AST and inserts the instrumentation code. The
original source files are over-written with the help of 'Rewriter'
class.

The tool reads the list of functions to instrument from an input file,
and also generates a couple of header files with the required
definitions for the instrumentation calls. It opens two o/p file
streams to write to the header files.

I wish to convert this tool to a Clang plugin so that I can use
command line options during the build process. This way, I won't have
to run the tool separately before building.

Can someone please let me know how easy/difficult is it going to be? I
hope that it is possible.

Should be pretty easy - the plugin is based on the frontend action, just
like the libtooling stuff. Main problem will be to manage the new files you
generate within your build system.

Thanks for the reply, Manuel !

Yes, I got it. It can be converted.

Thanks and regards,
Sandeep.