-ast-dump-xml flag

Hi all,

I’ve been trying to get the Clang-AST from compiling a simple C source file; the -ast-dump flag works just fine, but I’m having trouble with the -ast-dump-xml flag. A quick google search says that it should work when using Clang built in debug mode, but I don’t seem to be able to make it work. So my question is this; is this flag supported in the current version of Clang? FYI, I’ve just built Clang from the SVN repo source, so my version is:

clang version 3.5.0 (trunk 206772)
Target: x86_64-unknown-linux-gnu
Thread model: posix

I’m on a 64-bit ubuntu, with kernel 3.8.0-29 generic. Any help would be mostly appreciated!

Best,

Spyros

Hi Spyros,

XML dumping features have been removed because they were made redundant by clang's library architecture.

The preferred way to consume AST programmatically is via libclang. You could process this and emit XML from your application if needed.

For debugging you can also use the textual -ast-dump but be aware it may be missing bits.

Alp.

Would it be worthwhile to write a tool which uses the API and generates the previous XML format? This seems like both a useful forward migration path for existing users and a nice demonstration of how to use the programmatic APIs.

Philip

Would it be worthwhile to write a tool which uses the API and generates the previous XML format? This seems like both a useful forward migration path for existing users and a nice demonstration of how to use the programmatic APIs.

So, I think it's worthwhile as long as your tool does something clever -- like making use of a third-party XML library instead of trying to printf it to stdout, a luxury that wasn't available to the past efforts.

Another idea might be to do it with the Python binding -- using reflection it could perhaps be done in dozen lines.

(Broadly speaking though there shouldn't be a need for intermediate XML dumps when there are great options like libclang, libtooling with their own efficient serializations.)

Alp.