[cfe-dev] Clang -ast-dump-xml question

Vane, Edwin edwin.vane at intel.com
Wed Mar 6 08:58:11 PST 2013

As Doug mentioned, a far easier solution would be to use a clang plugin with an AST consumer that simply serializes the AST in a way you want. Check out http://clang.llvm.org/docs/LibTooling.html and friends under the "Using Clang as a Library" from http://clang.llvm.org/docs/.

-----Original Message-----
From: Matthias Grimmer [mailto:grimmer at ssw.jku.at] 
Sent: Wednesday, March 06, 2013 10:39 AM
To: Vane, Edwin
Subject: Re: [cfe-dev] Clang -ast-dump-xml question

No, not really. The goal was to get a serialized version of the AST (and all the declarations, like records...) pretty quick.
It would have been nice, if there was a tool for this.
We will think of a good file format to serialize the clang ASTs and all the other informations.
Can you recommend ASTDumper.cpp as a good reference solution for our task? It seams that ASTDumper.cpp / -ast-dump does pretty much what we want, except from the output format.

Thanks in advance

- Matthias

On 03/06/2013 03:28 PM, Vane, Edwin wrote:
> Any reason you couldn't write a clang tool to work directly on the AST to produce the different code representation?
> -----Original Message-----
> From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] 
> On Behalf Of Matthias Grimmer
> Sent: Tuesday, March 05, 2013 5:42 AM
> To: cfe-dev at cs.uiuc.edu
> Subject: [cfe-dev] Clang -ast-dump-xml question
> Hi
> we are using clang and its -ast-dump-xml feature. Our goal is to convert the serialized clang-AST to a different code representation.
> We think that the output, that -ast-dump-xml produces, is not well suited for parsing. Statements are represented as ASCII styled trees and also contain parts that confuse XML parsers (e.g. <line:18:2, col:18>).
> Is there a better way to get a serialized version of the clang AST (XML, or any other format that is easier to parse)?
> We would like to avoid writing a clang AST visitor for this purpose.
> Thanks in advance
> - Matthias Grimmer
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list