On Tue, Jul 26, 2011 at 10:59 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div class="im"><br><div><div>On Jul 26, 2011, at 9:17 PM, Talin wrote:</div><br><blockquote type="cite"><span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium">Here's an example of how this would be used: In the constructor for ConstantVector, there's an assert:<div>

<br><div><div><div><font face="'courier new', monospace">  assert(C->getType() == T->getElementType() &&</font></div><div><font face="'courier new', monospace">         "Initializer for vector element doesn't match vector element type!");</font></div>

</div><div><br></div><div>I would change this to:</div><br><div><div><font face="'courier new', monospace">  ASSERT_STRM(C->getType() == T->getElementType(),</font></div><div><font face="'courier new', monospace">    "Initializer for vector element " << I - V.begin() << " with type " <<</font></div>

<div><font face="'courier new', monospace">    C->getType() << " doesn't match vector element type " <<</font></div><div><font face="'courier new', monospace">    T->getElementType());</font></div>

<div><br></div></div><div>With more detailed assertions like this, a much larger class of programmer errors can be diagnosed without having to go into the debugger.</div><div><br></div><div>Because the stream is a raw_ostream, LLVM types and values can easily be printed to the stream without having to convert them to string form.</div>

</div></div></span></blockquote><br></div></div><div>I'm unconvinced that this is worth it at all.  This is only going to allow you to "avoid going into the debugger" in the most trivial cases.</div><div><br>

</div></div></blockquote><div>Question - are you opposed to having a general "assertion with streamed arguments" facility in llvm/Support at all, or are you merely opposed to the work involved in replacing the existing assertions en-masse? If it's the latter, I'll make you a deal - every time I get an assert that I don't think gives me enough information, I'll send a patch to improve it. But that can only happen if the general mechanism is in place first. And I'd use that general mechanism in my own code regardless of whether it's used in LLVM or not.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div></div><font color="#888888"><div>-Chris</div></font></div></blockquote>

</div><br><br clear="all"><br>-- <br>-- Talin<br>