[cfe-dev] looking for an AST traversal example

josef maxim pohl josef.m.pohl at gmail.com
Tue Nov 1 09:43:42 PDT 2011


Thanks Garrison.  I appreciate the example.

Josef

On Mon, Oct 31, 2011 at 9:59 AM, Garrison Venn <gvenn.cfe.dev at gmail.com>wrote:

> Attached is a very non-complete, and simple example which I created awhile
> back. Even though this it uses RecursiveASTVisitor, one can get
> the basics on how to use ASTConsumers from it. One caveat here is that
> if you do want to use RecursiveASTVisitor, you must really have a good
> understanding of tablegen generated header files such as DeclNodes.inc.
> Using these files, along with redefined macros, is where the real power
> of RecursiveASTVisitor manifests itself (IMHO). The second caveat is that
> there
> is no cleanup here. For example I'm including headers (such as some JIT
> stuff), which I do not need. This was just a quick hack which got me
> started.
>
> Hope this helps
>
> Garrison
>
> PS: This example was tested with TOT
>
>
>
>
> On Oct 31, 2011, at 9:11, josef maxim pohl wrote:
>
> > Hi there,
> >
> > I am still on my search for a relatively simple example to work with
> which creates an AST from a source file and traverses it doing even the
> most rudimentary tasks.  Does anyone have such an example?  Or does anyone
> have any tips on how to go about building one?
> >
> >
> > What I am attempting to do is build a stand-alone application (ie not a
> plugin) that sets up the AST (ie build preprocessor, set appropriate
> options (header search, etc), initialize ParseAST routine, ...) and then
> use an ASTConsumer to traverse the tree.
> >
> > Any feed back would be greatly appreciated.
> >
> > Thanks,
> > Josef
> >
> >
> >
> > _______________________________________________
> > 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/20111101/5a25ff9f/attachment.html>


More information about the cfe-dev mailing list