[cfe-dev] accessing clang's AST

Octav Chipara ochipara at gmail.com
Fri Feb 26 20:14:07 PST 2010

In lib/FrontEnd there is quite a bit of code for printing the AST to XML.
Does that work and if so how can you invoke it?

Thanks a bunch,
-- Octav

On Fri, Feb 26, 2010 at 7:18 PM, Douglas Gregor <dgregor at apple.com> wrote:

> The AST dumper does not handle all decl kinds (nor does the AST printer,
> IIRC). It would be helpful if someone were to contribute a patch dumping the
> remaining decl kinds.
> Sent from my iPhone
> On Feb 26, 2010, at 7:03 PM, Charles Davis <cdavis at mymail.mines.edu>
> wrote:
>  Octav Chipara wrote:
>>> Dear Chip,
>>> Thanks for the info. Is there an plug-in the exports the AST?
>> No. However, it's really not necessary. If you derive a class from
>> ASTConsumer (from the AST library), you will be fed each top-level
>> declaration from the AST as the parser builds it up (see
>> ASTConsumer::HandleTopLevelDecl()). Or, you can traverse the AST all at
>> once by implementing the HandleTranslationUnit() method (also in
>> ASTConsumer), which receives a translation unit decl from which you can
>> get every other node in the AST.
>>> I tried
>>> the ast-dump, however, it crashes:
>>> 0x10490e360 Assertion failed: (0 && "Unexpected decl"), function
>>> DumpDeclarator, file StmtDumper.cpp, line 263.
>> That's not supposed to happen.
>> Can we see the source that caused this? Put it up on pastebin or some
>> such.
>> Chip
>> _______________________________________________
>> 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/20100226/bde7d9f5/attachment.html>

More information about the cfe-dev mailing list