How to use clang::tooling::Transformer?

Hello everyone,

I am looking into source-to-source translation with LLVM.
I found a tutorial but it looks out-of-date (~7 years old) - https://eli.thegreenplace.net/2014/05/01/modern-source-to-source-transformation-with-clang-and-libtooling/

One of the latest answers regarding the same topic in this mailing pointed to ‘Transformer’ class. The ‘RewriteRule’ looks similar to ASTMatcher, except the ‘changeTo’ part - which is static - can it be made dynamic? (different replacement for each match). I couldn’t understand how to construct ‘ChangeConsumer’ object to instantiate a ‘Transformer’-based tool.
I couldn’t find any example or tutorial on how to use this interface with a stand-alone tool. Any pointer to documentation?

Thanks in advance!

1 Like

Did we get an answer this question? It will helpful to me if someone can answer this.