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

Yang Ye yeyangever at gmail.com
Tue Jun 29 13:38:59 PDT 2010


Thanks! So can anyone show me a full tool chain of functions using the
Clang API, and a c++ file as input, then get the output of AST or CFG?
(not using clang -cc1 -ast-dump xx.cpp)



-----------------------
Yang Ye
646-417-0326

Ph.D.
Department of Computer Science
The Fu Foundation School of Engineering and Applied Science Columbia University
yy2314 at columbia.edu



On Mon, Jun 28, 2010 at 12:53 AM, Chandler Carruth <chandlerc at google.com> wrote:
> 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




More information about the cfe-dev mailing list