Howto inject code

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

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

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