[cfe-dev] Question about printing abstract syntax tree in Clang

Chandler Carruth chandlerc at google.com
Mon Jun 28 00:53:20 PDT 2010


On Sun, Jun 27, 2010 at 10:17 PM, Yang Ye <yeyangever at gmail.com> wrote:

> Hello everyone,
>
> This is Yang Ye, a new researcher working on Clang. I want to use
> clang to print out the abstract syntax tree in a human readable, not
> getting the binary bytecode one.
> Can anyone show me how to use the API to do it?
>

Currently you can use 'clang -cc1 -ast-dump' to get this. The code is driven
from ASTPrinter defined here:
http://clang.llvm.org/doxygen/ASTConsumers_8cpp_source.html#l00034

However, if you're interested in this type of walk, I'd suggest you consider
the RecursiveASTVisitor:
http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html

It's not complete yet, so it misses a few parts of the AST, but it's being
actively developed by several folks who are interested in similar walks of
the AST.

-Chandler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100628/4a3b5c58/attachment.html>


More information about the cfe-dev mailing list