[cfe-dev] AST XML dump

Olaf Krzikalla Olaf.Krzikalla at tu-dresden.de
Wed May 20 06:01:42 PDT 2009


Hi,

Thanks for your comments. By now I understand why Sebastian objected at 
first of all. I initially used the organization that was used for AST 
dumping.
But I've changed that and thus became really minimal intrusive. Find 
attached another patch which respected some comments and should now 
compile out of the box (tested with VC and cygwin) with the current 
revision. I also added the output for ast-printing.c as found in the 
test suit. As you can see the _Complex type is one of the features not 
implemented yet.

Douglas Gregor schrieb:
> 1) Why do we need to build an in-memory representation of the XML 
> document just to print it? The in-memory representation itself isn't 
> likely to be useful for much, since we're not providing any way of 
> directly manipulating the in-memory representation. Would it be 
> possible, instead, to stream the XML representation to disk directly, 
> rather than building it all in memory? Doing so would save a lot of 
> memory and should improve performance, since we won't be doing so much 
> string copying and manipulation. Also in the same vein: there are 
> quite a few std::map's to strings. These should probably be 
> llvm::DenseMaps, and is it possible to map to something more efficient 
> than a std::string?
>
> 2) I see that you've added a dumpXML routine into Stmt. Is there some 
> benefit to having this as a method on Stmt, or can we just separate 
> the XML-dumping functionality completely, putting it all into an AST 
> consumer?
Most of these things are done by now.
>
> 3) I feel that it is very important that we have a proper XML schema 
> before we claim to generate good XML. It's also important for testing: 
> we'd like to be able to, e.g., generate XML from some translation unit 
> and then verify that the XML meets the known schema.
>
Documentation is indeed the most important TODO. However I'm not 
completely convinced by the current format yet.  I had some hope that 
there is already an existing inter-language de-facto standard for ASTs 
but beside GENERIC I didn't found anything. And at a first glance 
GENERIC seems to be too low level at least for my purposes.
> It might be better to use the macro invocations in 
> include/clang/AST/TypeNodes.def to enumerate and switch on the various 
> kinds of type nodes. It's generally cleaner, and protects this code 
> better against changes in the type hierarchy.
Thats another TODO. In fact I don't like all the dyn_cast chains either.

Best
Olaf Krzikalla

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ast-printing.xml
Type: text/xml
Size: 40960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090520/5dec448b/attachment.xml>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: firstXML.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090520/5dec448b/attachment.ksh>


More information about the cfe-dev mailing list