[cfe-dev] Instances of Variable Usage (SSA form)

Manuel Klimek klimek at google.com
Sun Oct 21 23:14:22 PDT 2012


On Fri, Oct 19, 2012 at 9:42 PM, Mohammad Adil <madil90 at gmail.com> wrote:

> 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).


The easiest way is to not code your own Clang setup, and use either
- a clang plugin (http://clang.llvm.org/docs/ClangPlugins.html)
- or LibTooling (http://clang.llvm.org/docs/LibTooling.html)

Cheers,
/Manuel


> Regards,
> Adil
>
>
> On Fri, Oct 19, 2012 at 10:19 PM, Anna Zaks <ganna at apple.com> wrote:
>
>> You could search for all DeclRefExprs that refer to the particular
>> variable declaration (by doing an AST walk).
>>
>> Note that this will find only syntactic references to a particular
>> variable, but will not trace the data flow. For example,
>> int x = 0;
>> int y = x;
>> use(y); // This will not be a use of x.
>>
>> (SSA form just guarantees that there is only a single assignment for each
>> variable.)
>>
>> Anna.
>> On Oct 18, 2012, at 11:21 PM, madil90 <madil90 at gmail.com> wrote:
>>
>> > Hi,
>> >   I want to use clang to find out all the instances of a variable usage.
>> > e.g. I want to find out every place where the variable 'x' was used? I
>> know
>> > that, in theory, this problem can be solved using the SSA form. How can
>> I do
>> > this in clang?
>> >
>> > Regards,
>> > Adil
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://clang-developers.42468.n3.nabble.com/Instances-of-Variable-Usage-SSA-form-tp4027566.html
>> > Sent from the Clang Developers mailing list archive at Nabble.com.
>> > _______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
>
> --
> Mohammad Adil
> LUMS SSE
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121022/f9ab5d67/attachment.html>


More information about the cfe-dev mailing list