Run clang plugin as additional step

Hi all,

I want to develop a hook that will only modify the AST as an intermediate step, handing off the modified AST for the next pipeline stages (codegen, etc.). I thought that plugins were the way to go but I found that when using them Clang simply yields control of the pipeline to them, meaning further stages are not run and the execution of the plugin is the last one. Is this understanding correct?
If so, how can I execute a plugin as a simple hook in the whole process which modifies the in-memory AST before code generation?
Or, how can I trigger codegen inside my plugin if the above is not possible?
Any other ideas are welcome, possibly I’m doing things at the wrong place.


I found the -add-plugin option, but it doesn’t really let me modify the AST, the relevant part is in this file line 147. Due to this explicit restriction I feel that modifying the AST through plugins is not a solution. Where should I do this?