Hi all,<div><br></div><div>This is the first step of what we were talking about: I removed the separate clang-ast-dump and added -ast-dump-filter option to clang -cc1. This option works both with -ast-dump and -ast-print and filters AST Decl nodes to dump by a substring of a qualified name. I also changed the behavior of Decl::dump method to really dump the node and not just print it to llvm::errs().</div>
<div><br></div><div>Please review the patch so I can go on with making Decl::dump() output more structured and informational.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 20, 2012 at 5:48 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class="im"><div>On Jul 19, 2012, at 10:00 AM, Alexander Kornienko <<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>> wrote:</div>
<br><blockquote type="cite"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 17, 2012 at 7:55 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Okay, that's fair; but this could trivially be added as a parameter to the existing XML dumper. We don't need a whole separate, single-purpose tool for this.<br></div>
<div>...</div><div>
> Overall, a way to dump the AST is critical to writing clang tools,<br>
> especially while you're learning the AST. Being able to dump parts of<br>
> the AST of the source you want to work on makes it far easier to find<br>
> out why the AST looks the way it does at a certain place where your<br>
> refactoring doesn't work than trying to reproduce that with a minimal<br>
> source file that doesn't use any non-builtin includes. Many tool<br>
> writers are not hardcore C++ experts (the ones that are obviously<br>
> don't need the tool that much), and one of the goals for us is to make<br>
> writing C++ tools possible for normal people ;)<br>
<br>
</div>The XML dump isn't really a great way to learn the AST. Our normal dumper is far better for that purpose, IMO, because it's more complete and produces less noise.</blockquote></div><div><br></div><div>Basically, we don't need XML, we only need a format which is closer to an actual AST structure than just a C++ listing. Both XML and normal dumper use the same format for statements, which is nice. The problem with the normal dumper is how it outputs declarations. It basically outputs fragments in C++, which isn't much useful for those trying to figure out how AST looks like for declarations.If we could change its output to that LISP-style format used for statements, it would be much more helpful in our use-case.</div>

<div><br></div><div>Are there reasons for the normal dumper to exist in its current state? </div></div></blockquote><div><br></div></div><div>I think it's simply laziness.</div><div class="im"><br><blockquote type="cite">
<div class="gmail_extra"><div>If there are no serious reasons, I could work on switching it's format. Otherwise we could add another dump format for declarations (consistent with the one used for statements), or replace XML with it.</div>

<div><br></div><div>What do you think about this?</div></div></blockquote><div><br></div></div><div>I think this is the right way to go. -ast-dump should dump declarations in the same tree format used for statements. -ast-print will still persist for those who want to see pretty-printed ASTs rather than the actual form of the ASTs.</div>
<div class="im"><br><blockquote type="cite"><div class="gmail_extra"><div>I would also be glad to add an "-ast-dump-filter" option to clang, so we could select AST declaration nodes to dump by a substring. This would remove any need in a separate clang-ast-dump tool.</div>

</div></blockquote><br></div></div><div>That would be great!</div><div><br></div><div><span style="white-space:pre-wrap">     </span>- Doug</div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div><font color="#666666"><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(213,15,37);border-right-color:rgb(213,15,37);border-bottom-color:rgb(213,15,37);border-left-color:rgb(213,15,37);padding-top:2px;margin-top:2px">Alexander Kornienko |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(51,105,232);border-right-color:rgb(51,105,232);border-bottom-color:rgb(51,105,232);border-left-color:rgb(51,105,232);padding-top:2px;margin-top:2px"> Software Engineer |</span></font><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(0,153,57);border-right-color:rgb(0,153,57);border-bottom-color:rgb(0,153,57);border-left-color:rgb(0,153,57);padding-top:2px;margin-top:2px"><font color="#666666"> </font><a href="mailto:alexfh@google.com" style="color:rgb(17,85,204)" target="_blank">alexfh@google.com</a> |</span><span style="border-top-width:2px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(238,178,17);border-right-color:rgb(238,178,17);border-bottom-color:rgb(238,178,17);border-left-color:rgb(238,178,17);padding-top:2px;margin-top:2px"> <a value="+35315435283" style="color:rgb(17,85,204)">+49 151 221 77 957</a></span></div>
</div><div><font color="#666666"><span style="background-color:rgb(255,255,255);font-family:Arial,Verdana,sans-serif">Google Germany GmbH | </span><span style="background-color:rgb(255,255,255);font-family:Arial,Verdana,sans-serif">Dienerstr. 12 | </span><span style="background-color:rgb(255,255,255);font-family:Arial,Verdana,sans-serif">80331 München</span></font></div>
<br>
</div>