Douglas,<div><br></div><div>What do you think about moving AST dumping from clang -cc1 to a separate tool (but leaving implementation inside clang libraries, so it can be used for debugging the compiler code)? As this functionality is still interesting to many developers (and I'd say that this interest increases), more features can be implemented inside the tool, which would never be implemented inside a compiler. This way we could remove dependencies on assertions and keep the compiler free from functions useful only while debugging AST-related code.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 17, 2012 at 6:40 PM, Matthieu Monrocq <span dir="ltr"><<a href="mailto:matthieu.monrocq@gmail.com" target="_blank">matthieu.monrocq@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div><div class="h5">On Mon, Jul 16, 2012 at 7:44 PM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div>Hi all,</div><div><br></div><div>I've recently implemented a tool named clang-ast-dump, which allows to dump selectively an AST of user-specified translation units. It's a really simple tool now, most of it's code is node filtering. The rest is done by <font face="courier new, monospace">Decl::dumpXML</font>.</div>



<div><br></div><div>Now the problem: Decl::dumpXML does nothing when compiled with -DNDEBUG. I assume that initially this method was meant to be only helpful during debugging of clang code, but now there are a couple of reasons to review this decision, I think:</div>


<div>  * clang -cc1 mode has a command line option "<font face="courier new, monospace">-ast-dump-xml</font>", which uses <font face="courier new, monospace">dumpXML</font>, and currently it won't work with <font face="courier new, monospace">-DNDEBUG</font> (e.g. when builing with CMake: Release configuration + <font face="courier new, monospace">LLVM_ASSERTIONS_ENABLED=OFF</font>);</div>


<div>  * clang-ast-dump tool uses it.</div><div><br></div><div>A comment in <font face="courier new, monospace"><b>DumpXML.cpp</b></font> states:</div><div><span style="color:rgb(136,0,0);font-family:monospace;font-size:medium;line-height:16.25px;white-space:pre-wrap">// Only pay for this in code size in assertions-enabled builds.</span><br>


</div><div><br></div><div>But having <font face="courier new, monospace">-ast-dump-xml</font> option conflicts with this idea: either we have to disable this option completely in non-assertion-enabled builds, or we have to drop this idea of not-having the <font face="courier new, monospace">dumpXML</font> implementation in them. The third option would be to drop the <font face="courier new, monospace">-ast-dump-xml</font> option completely and instead use <font face="courier new, monospace">clang-ast-dump</font> tool when needed. In this case we could only use an implementation of <font face="courier new, monospace">Decl::dumpXML</font> in the tool and exclude it from clang binary.</div>

<span><font color="#888888">
<div><br></div>-- <div>Regards,</div><div>Alexander Kornienko </div>
</font></span><br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>I think the latter solution (separate tool) would perhaps make the most sense. It seems to me that we get the best of both worlds: a lean compiler and a verbose (and possibly richer and richer) tool for debugging.<br>

<br>If the tool had been maintained on a separate repository, the question of bitrot would have risen, however if we speak about a tool maintained within the clang repository (albeit a dedicated directory) then we can have the build bots verifying that it compiles and its test-suite pass so that modifications on the AST are propagated.<span class="HOEnZb"><font color="#888888"><br>

<br>-- Matthieu<br>
</font></span></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>