On Wed, Jul 17, 2013 at 4:18 PM, Pavan Pattanada <span dir="ltr"><<a href="mailto:pattanad@uci.edu" target="_blank">pattanad@uci.edu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>By "same", I mean, their ASTs to be the same to start with. I am working on a tool, which is used to syntactic/semantic similarity between two versions of the code base. So far, I have been able to get the FunctionDecls of both versions of a function into memory. But I am not sure how to compare them.</div>
</div></blockquote><div><br></div><div>This is still a little imprecise. Should functions compare equal if variables have been renamed between them? What if an expression has been rewritten into a trivially equivalent form (for instance, parentheses were added or removed, or p->x was changed to (*p).x)?</div>
<div><br></div><div>Stmt::Profile does nearly what you want (it's the mechanism we use to determine if two dependent expressions are equivalent for the purposes of template redeclaration matching), but it will treat</div>
<div><br></div><div> void f() { int n; }</div><div> void g() { int n; }</div><div><br></div><div>as having different bodies, because they do not declare the same variable. That's probably not very hard to fix.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="HOEnZb"><font color="#888888"><div class="gmail_extra">~Pavan<br></div></font></span><div class="gmail_extra">
<br><br><div class="gmail_quote"><div class="im">On Wed, Jul 17, 2013 at 3:42 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>
</div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On Wed, Jul 17, 2013 at 10:10 AM, Pavan Pattanada <span dir="ltr"><<a href="mailto:pattanad@uci.edu" target="_blank">pattanad@uci.edu</a>></span> wrote:<br>
</div><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>Hi, <br></div>I need to compare two versions of the same clang::FunctionDecl function body(a function in C). I would need to compare them statement by statement and say if the two versions are the same. Is there a neat way to do this in the clang framework? </div>
</div></blockquote><div><br></div></div><div>This question is too vague to answer: what do you mean by "the same"? Same source text, same tokens, same tokens other than variable naming, something else?</div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br>