<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 23, 2014 at 4:03 PM, Krishna Narasimhan <span dir="ltr"><<a href="mailto:krishna.nm86@gmail.com" target="_blank">krishna.nm86@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks a lot Klimek,<div><br></div><div>The reason I primarily wanted an AST transformation was the inherent issues with co dependent multiple transformations.</div>
<div><br></div><div>For eg, lets say there is a node A which i just transformed and a predecessor node B which needs to be transformed based on the transformed version of A, i might need to include that transformed A node somewhere or flag it appropriately right?</div>
</div></blockquote><div><br></div><div>Well, generally, changing the AST and re-running an analysis over the AST, or changing the source code, re-parsing the AST, and then re-running an analysis should be equivalent in expressiveness.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div>I will look into that issue</div><div><br></div><div>About the macros. Are there any specific code locations I could look at to get this preprocessed token streams to make sense of the macros?</div></div></blockquote>
<div><br></div><div>Look at SourceLocations, which can be resolved via the SourceManager.</div><div><br></div><div>Cheers,</div><div>/Manuel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><br></div><div>
<br></div><div>P.S: I have included the clang mailing list. :-) </div><div><div><div class="h5"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Manuel Klimek</b> <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span><br>
Date: Thu, Jan 23, 2014 at 1:12 PM<br>Subject: Re: Student of prof. Reichenbach with questions on clang ast<br>To: Krishna Narasimhan <<a href="mailto:krishna.nm86@gmail.com" target="_blank">krishna.nm86@gmail.com</a>><br>
<br><br><div dir="ltr">
<div class="gmail_extra"><div class="gmail_quote"><div>On Thu, Jan 23, 2014 at 1:08 PM, Krishna Narasimhan <span dir="ltr"><<a href="mailto:krishna.nm86@gmail.com" target="_blank">krishna.nm86@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi, I am a student of Prof. Dr. Reichenbach .<br>
I have two questions regarding Clang(which I plan to use for my transformations):</p>
<p dir="ltr">1) How do i perform a transformation on the AST. I see that it is immutable. Are there support in Clang for this or external tools?</p></blockquote></div><div>Nope. It's hard to change a C++ AST in a way that doesn't break its invariants. What we prefer to do (and for which tools exist) is to use the AST to figure out which code to change, and then change the code (textually). Clang has very good support for finding out what code models which part of the AST.</div>
<div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr">2) Is there a way to prevent the pre processing (or rather) a way to modify an AST that is not the pre processed version of the program. For eg, if i want to refactor a #define, i currently have no way. Or?</p>
</blockquote></div></div></div><div class="gmail_extra">Again, no. But Clang's preprocessed token stream has all information to see how macros are expanded, so you *can* refactor a #define.</div><div class="gmail_extra">
<br>
</div><div class="gmail_extra">In general, I'd suggest you always include clang's developer mailing list (cfe-dev) when asking such questions, as they're often interesting for other people ;)</div><div class="gmail_extra">
<br></div><div class="gmail_extra">Cheers,</div><div class="gmail_extra">/Manuel</div></div>
</div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br>-----------------------------------------------------<br>I dare do all that may become a man; Who dares do more, is none - Macbeth, twelfh night!<br>
Regards<br> KrishnaThanks</font></span></div>
</div>
</blockquote></div><br></div></div>