Hi.<br><br><a href="http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html">http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html</a> <br><a href="http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html">http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html</a> <div>

<br>You can get a TU declaration from ASTContext::getTranslationUnitDecl(). Then since it derives from DeclContext, you can use all the iterators available to get at the declarations contained inside it.<br><br><br>On Thu, Aug 16, 2012 at 3:55 PM, Journeyer J. Joh <<a href="mailto:oosaprogrammer@gmail.com">oosaprogrammer@gmail.com</a>> wrote:<br>

><br>> Thank you very much Alexander Kornienko! You replied to me so fast!<br>><br>> This would be very helpful for me!<br>><br>><br>><br>> But I'd like to also know where I need to look to find the result of<br>

> AST Parsing in the source code.<br>><br>> I tried to find it from 'ADecl' after 'P.ParseTopLevelDecl(ADecl)' in<br>> the global function ParseAST(). But I couldn't find it there using<br>

> ddd.<br>><br>> Could somebody let me know where I need to look? (with gdb or ddd)<br>><br>> Thank you very much!<br>><br>> Journeyer J. Joh<br>><br>> 2012/8/16 Alexander Kornienko <<a href="mailto:alexfh@google.com">alexfh@google.com</a>>:<br>

> ><br>> ><br>> > On Thu, Aug 16, 2012 at 4:14 PM, Journeyer J. Joh <<a href="mailto:oosaprogrammer@gmail.com">oosaprogrammer@gmail.com</a>><br>> > wrote:<br>> >><br>> >> Hello list,<br>

> >><br>> >> I am recently reading the source code of the Clang/LLVM with gdb.<br>> >> Among others I read about the AST Parsing these days. But finding the<br>> >> result of this parsing is difficult for me.<br>

> >><br>> >> I'd like to know where I can find the result of AST Parsing.<br>> >><br>> >> I found where the AST Parsing is commited. It's shown below.<br>> >><br>> >> break clang::ParseAST<br>

> >> break clang::Parser::ParseTopLevelDecl<br>> >> break clang::Parser::ParseExternalDeclaration<br>> >> break clang::Parser::ParseDeclarationOrFunctionDefinition<br>> >> break clang::Parser::ParseDeclOrFunctionDefInternal<br>

> >> break clang::Parser::ParseDeclarationSpecifiers<br>> >> break clang::Parser::ConsumeToken<br>> >> break clang::Parser::ParseDeclGroup<br>> >> break clang::Parser::ParseDeclarator<br>

> >> break clang::Parser::ParseDeclaratorInternal<br>> >> break clang::Parser::ParseDirectDeclarator<br>> >> break clang::Parser::ParseFunctionDeclarator<br>> >> break clang::Sema::ActOnStartFunctionDeclarator<br>

> >> break clang::Parser::ParseParameterDeclarationClause<br>> >> break clang::Parser::ParseDeclarationSpecifiers<br>> >> break clang::Parser::ParseDeclarator<br>> >> break clang::Parser::ParseFunctionDefinition<br>

> >> break clang::Parser::ParseCompoundStatementBody<br>> >> break clang::Parser::ParseStatementOrDeclaration<br>> >> break clang::Parser::ParseDeclaration<br>> >> break clang::Parser::ParseExprStatement<br>

> >><br>> >> This is my break points used in gdb.<br>> >><br>> >> I was able to trace the parsing of the C source code,<br>> >> BUT I couldn't find the result of this AST Parsing.<br>

> >><br>> >> I'd like to know where I can find the result of this AST Parsing.<br>> >> I'd like to find it using gdb.<br>> >><br>> >> Or, I wonder if there is any way for me to print out the Parsed AST.<br>

> >> Any utility or compiler options?<br>> ><br>> > You can use<br>> ><br>> > clang -cc1 -ast-dump filename.cpp [header search and other options]<br>> ><br>> > or<br>> ><br>

> > clang-check -ast-dump filename.cpp -- [header search and other options]<br>> ><br>> > to dump the AST parsed from filename.cpp. You can also use -ast-dump-filter<br>> > for both to filter dumped declarations by a certain substring in name.<br>

> ><br>> >><br>> >><br>> >> Thank you very much in advance.<br>> >><br>> >> Have a good day!<br>> >> --<br>> >> ----------------------------------------<br>

> >> Journeyer J. Joh<br>> >> o o s a p r o g r a m m e r<br>> >> a t<br>> >> g m a i l  d o t  c o m<br>> >> ----------------------------------------<br>> >> _______________________________________________<br>

> >> cfe-dev mailing list<br>> >> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>> >> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>

> ><br>> ><br>> ><br>> ><br>> > --<br>> > Best regards,<br>> > Alexander Kornienko<br>> ><br>><br>><br>><br>> --<br>> ----------------------------------------<br>

> Journeyer J. Joh<br>> o o s a p r o g r a m m e r<br>> a t<br>> g m a i l  d o t  c o m<br>> ----------------------------------------<br>> _______________________________________________<br>> cfe-dev mailing list<br>

> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br><br><br><br><br>--<br>João Matos</div>