Patch source with instrumentation without altering original code

I want to use libtooling to generate instrumentattion code for debug builds. I will manage to run my generator from cmake, but i don’t really know how i could patch my Instrumentation into the source without altering the normal files.

At least if i can not manage to output complete source files from my generator.

Hope my question hast not been asked too often

Do you have an example of how this would work without CMake (i.e., what the command line looks like for doing what you want at all)? If not, I think this may be more of an LLVM/Clang question at first, but once it’s known how to do it outside of CMake, translating it into how to make CMake generate that information would go here.