I have an existing and working source-to-source code modification tool using libtooling. Now I want to integrate this tool into clang, so users can compile the modified source code without actually saving it somewhere.
The modification part isn't problematic, Matchers + Rewriters work the same way with clang, my problem is how to tell the compiler to reparse the source code after my changes.
My progress so far:
- I found a conversation on cve-dev, but without specific information how to do it
- I also found clang::ASTUnit::Reparse, but I couldn't figure out how to call it. In the clang sources nothing uses it, and my every try was rewarded with crashes.
- There was a similar question in StackOverflow, but without a good answer
- There are some plugins tools like traces, which do the same source modification, but it just calls the compiler two times.
I'm hope that based on the first two eventually I find a working solution, but maybe someone knows the answer already, and could help me with an example, or at least more specific instructions how to implement it?