<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Committed r162773. Thanks, all.<div><br></div><div> Chad</div><div><br><div><div>On Aug 28, 2012, at 11:10 AM, Chandler Carruth wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 28, 2012 at 11:08 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank" class="cremed">rjmccall@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 class="im">On Aug 28, 2012, at 11:05 AM, Chad Rosier wrote:<br>
> On Aug 28, 2012, at 10:48 AM, Dmitri Gribenko wrote:<br>
>> On Tue, Aug 28, 2012 at 10:43 AM, Chad Rosier <<a href="mailto:mcrosier@apple.com" class="cremed">mcrosier@apple.com</a>> wrote:<br>
>>> +std::string AsmStmt::generateAsmString(ASTContext &C) const {<br>
>>> + StmtClass stmtClass = getStmtClass();<br>
>>> + if (stmtClass == Stmt::GCCAsmStmtClass)<br>
>>> + return static_cast<const GCCAsmStmt*>(this)->generateAsmString(C);<br>
>>> + if (stmtClass == Stmt::MSAsmStmtClass)<br>
>>> + return static_cast<const MSAsmStmt*>(this)->generateAsmString(C);<br>
>>> + llvm_unreachable("unknown asm statement kind!");<br>
>>> +}<br>
>><br>
>> It is conventional to use cast<> in such cases.<br>
><br>
> I based these changes off of John's work in r125183. I don't claim to be an expert on the use of casts, but I'm guessing John used the static_cast to elide the run-time checks. John, please correct me if I'm wrong…<br>
<br>
</div>I don't remember, but it's a bit different in macro-metaprogrammed code. Here you might as well use cast<>.</blockquote><div><br></div><div>Better yet, use dyn_cast and remove the raw getStmtClass...</div>
<div><br></div><div>if (GCCAsmStmt *GCCAS = dyn_cast<GCCAsmStmt>(this))</div><div> GCCAS->generateAsmString(C);</div><div>if (MSAsmStmt *MSAS = dyn_cast<MSAsmStmt>(this))</div><div> MSAS->generateAsmString(C);</div>
<div>llvm_unreachable(...); </div></div></div>
</blockquote></div><br></div></body></html>