Source-to-source Transformation


I am writing a tool using LibClang. Is there an efficient way to modify the abstract syntax tree? For instance, I need to transform an “if statement” to another kind of statement, and so on.
In other words, the feature that I am looking for is source-to-source transformation.
The only method that comes to mind, is manipulating the source code directly which does not seem like a neat and efficient thing to do.

Any advice on this matter would be appreciated.

Best regards,