<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Do you need to use ASTImporter, or was that just a starting point? LibTooling has a lot of support for editing code. clang-tidy tends to be the easiest place to start. Additionally, clang transformer can simplify the code editing parts with "rewrite rules": </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><a href="https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h" style="font-family:Arial,Helvetica,sans-serif">https://github.com/llvm/llvm-project/blob/master/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h</a></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><a href="https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Tooling/Transformer/RewriteRule.h" style="font-family:Arial,Helvetica,sans-serif">https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Tooling/Transformer/RewriteRule.h</a> </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">To your example, you'd write a matcher which identifies the node of interest and then edit the code with something like `insertAfter(node(IdBoundToInterestingNode), cat(...))`</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 21, 2020 at 9:22 AM samins KAlex via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><pre>Can I use ASTImporter for add some loop into function CompoundStatement node exactly in particular source location (or after some AST node between left bracket and right bracket)?
Importer(ToUnit->getASTContext(), ToUnit->getFileManager(), FromUnit->getASTContext(), FromUnit->getFileManager(),
Also
It seems, I need to get ASTContext object from node "to", because ASTImporter constructor takes ASTContext "from" and "to"? But how can I do it having only "from" and "to" nodes ?
</pre></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>