<div dir="ltr">It's generally considered that the AST invariants are too subtle/complex to use AST modification and AST->source conversion reliably. Refactoring/source code modification is generally encouraged to be done via textual edits generated from source location information in the AST.<br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 9, 2018 at 8:36 PM Ridwan Shariffdeen 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:garamond,serif;font-size:small">Hi,</div><div class="gmail_default" style="font-family:garamond,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:small">I am trying to build a tool which can insert new AST nodes to a AST tree obtained from a source code and generate the modified source code. For example add an if condition to a given location. <br><br>I have seen examples on ReWriter which can insert text, but I want to insert a proper AST node and generate the source code from the modified AST. </div><div class="gmail_default" style="font-family:garamond,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:small">For this purpose, I think I should be using ASTWriter and not ReWriter. Is there any documentation I can refer on how to implement this?</div><div class="gmail_default" style="font-family:garamond,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:small">Any help in this regard is highly appreciated. </div><div class="gmail_default" style="font-family:garamond,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:small">Thanks!</div><div class="gmail_default" style="font-family:garamond,serif;font-size:small">Ridwan</div></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="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>