On Fri, Oct 19, 2012 at 9:42 PM, Mohammad Adil <span dir="ltr"><<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thank you. This is exactly what I was looking for. I have a small issue though. I've used a CompilerInvocation and CompilerInstance to set up clang. Then I use parseAST to parse the clang AST. My program can't find standard C++ headers like <string> and <stdio.h>. How do I make clang automatically find system include directories (e.g. /usr/include etc).</blockquote>
<div><br></div><div>The easiest way is to not code your own Clang setup, and use either</div><div>- a clang plugin (<a href="http://clang.llvm.org/docs/ClangPlugins.html">http://clang.llvm.org/docs/ClangPlugins.html</a>)</div>
<div>- or LibTooling (<a href="http://clang.llvm.org/docs/LibTooling.html">http://clang.llvm.org/docs/LibTooling.html</a>)</div><div><br></div><div>Cheers,</div><div>/Manuel</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
<br></div><div>Regards,</div><div>Adil<div class="im"><br><br><div class="gmail_quote">On Fri, Oct 19, 2012 at 10:19 PM, Anna Zaks <span dir="ltr"><<a href="mailto:ganna@apple.com" target="_blank">ganna@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">You could search for all DeclRefExprs that refer to the particular variable declaration (by doing an AST walk).<br>

<br>
Note that this will find only syntactic references to a particular variable, but will not trace the data flow. For example,<br>
int x = 0;<br>
int y = x;<br>
use(y); // This will not be a use of x.<br>
<br>
(SSA form just guarantees that there is only a single assignment for each variable.)<br>
<br>
Anna.<br>
On Oct 18, 2012, at 11:21 PM, madil90 <<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
>   I want to use clang to find out all the instances of a variable usage.<br>
> e.g. I want to find out every place where the variable 'x' was used? I know<br>
> that, in theory, this problem can be solved using the SSA form. How can I do<br>
> this in clang?<br>
><br>
> Regards,<br>
> Adil<br>
><br>
><br>
<span><font color="#888888">><br>
> --<br>
> View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/Instances-of-Variable-Usage-SSA-form-tp4027566.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Instances-of-Variable-Usage-SSA-form-tp4027566.html</a><br>


> Sent from the Clang Developers mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div></div><span class=""><font color="#888888">-- <br>Mohammad Adil<div>LUMS SSE</div><br>
</font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>