[cfe-dev] Getting started with walking the AST

ret val retval386 at gmail.com
Wed Jun 15 11:36:56 PDT 2011


Its not the prettiest code ever, but I wrote something that gets function
names, function calls and function pointers. I just modified the
PrintFunctions example.

https://gist.github.com/1027771 or see the attachment

With PrintFunctionsConsumer you just implement the functions you want to
use. You can also make a constructor/destructor like normal.


On Tue, Jun 14, 2011 at 3:37 AM, Adam Smalin <acidzombie24 at gmail.com> wrote:

> Note: I am using LLVM and CLANG 2.9
>
> I want to start with someone basic. Like printing out all the function or
> class names. Or maybe all variables in a struct that is a type int. Anyways
> to get started i look at `llvm/tools/clang/examples`. I see
> clang-interpreter, in main.cpp theres nothing including AST and it seems
> like not what i want. The example PrintFunctionNames looks exactly what i
> want but theres no main(). I read it and it seems like HandleTopLevelDecl is
> the key function. I see instructions on how to use this on linux/mac but i
> rather do it on windows since i like debugging in VS.
>
> Moving on i looked at clang-wpa.cpp which seems to kickstart an
> analyzer/debugger/something but i cant build it! I have missing files and
> such. One such error is "error C2039: 'LAST_INHERITABLE' : is not a member
> of 'clang::attr'". Others i mention in a post here
> http://stackoverflow.com/questions/6326453/ Is the examples outdated? i am
> afraid to grab the main branch for more troubles. Does the example work on
> linux? and does it work on 2.9 tag or do i need to use a branch? (which?)
>
>
>
> _______________________________________________
> 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/20110615/e23cda60/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PrintFunctionNames.cpp
Type: text/x-c++src
Size: 3060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110615/e23cda60/attachment.cpp>


More information about the cfe-dev mailing list