Howto inject code

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

Howto inject code

Boris Kolpackov via cfe-dev
Greetings,

Clang is pretty impressive but I was wondering what is the best way to
inject code in an existing source file?

I would like to add parameters to all function declarations, function
calls, base classes and each compound statement.


Regards,
-Phil

_______________________________________________
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: Howto inject code

Boris Kolpackov via cfe-dev
I'd look at how things like the Sanitizers are implemented - as modifications during Clang's IR Generation step.

I'm not sure there are plugin extensibility points (or whether there could ever reasonably enough such extensibility points to make that worthwhile) - but when it comes to outright modifying the Clang source code, the Sanitizers should give you some sense of where/how one might do that.

- Dave

On Tue, Nov 14, 2017 at 7:59 PM Phil Bouchard via cfe-dev <[hidden email]> wrote:
Greetings,

Clang is pretty impressive but I was wondering what is the best way to
inject code in an existing source file?

I would like to add parameters to all function declarations, function
calls, base classes and each compound statement.


Regards,
-Phil

_______________________________________________
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: Howto inject code

Boris Kolpackov via cfe-dev
On 11/15/2017 10:43 AM, David Blaikie via cfe-dev wrote:
> I'd look at how things like the Sanitizers are implemented - as
> modifications during Clang's IR Generation step.
>
> I'm not sure there are plugin extensibility points (or whether there
> could ever reasonably enough such extensibility points to make that
> worthwhile) - but when it comes to outright modifying the Clang source
> code, the Sanitizers should give you some sense of where/how one might
> do that.

Ok thanks.

I personally believe it would be awesome to be able to edit the AST
tree, disregarding synchronization of the pointers to the original
source code and streaming out from scratch text based of the new AST
tree. That would simplify all operations.


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