<div>ASTImporter was a starting point. I realized rewritings at text level at particular position after some node was matched. Now I need to modify AST at tree (node) level:</div><div>- add some statements to function compound stmt, and after match new AST again</div><div>- perform another AST changing and so on and so on yet another.</div><div> </div><div>This way is more preferable, because I not need load source code many times.</div><div> </div><div>I have already found that it's possible:</div><div>1)   <a href="https://stackoverflow.com/questions/41550891/adding-nodes-to-clangs-ast">https://stackoverflow.com/questions/41550891/adding-nodes-to-clangs-ast</a></div><div>2)  <a href="http://clang-developers.42468.n3.nabble.com/Adding-nodes-to-Clang-s-AST-td4054800.html"> http://clang-developers.42468.n3.nabble.com/Adding-nodes-to-Clang-s-AST-td4054800.html </a></div><div>3) <a href="https://stackoverflow.com/questions/30451485/how-to-clone-or-create-an-ast-stmt-node-of-clang/30459339">https://stackoverflow.com/questions/30451485/how-to-clone-or-create-an-ast-stmt-node-of-clang/30459339</a></div><div><br />The similar thing was realized in project Scout <a href="https://tu-dresden.de/zih/forschung/projekte/scout/">https://tu-dresden.de/zih/forschung/projekte/scout/</a></div><div>or <a href="https://llvm.org/devmtg/2013-04/krzikalla-slides.pdf">https://llvm.org/devmtg/2013-04/krzikalla-slides.pdf</a></div><div> </div><div>Unfortunately these projects and tips are outdated. Maybe there is some general solution in modern (9-11 versions) llvm/clang.</div><div>In sum I need mechanism for development own source-to-source translator but changes must be in AST (not at textual) level<table><tbody><tr><td> </td></tr></tbody></table></div><div> </div>