<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 18, 2013 at 4:24 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@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"><br>
On Feb 15, 2013, at 3:59 PM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>> wrote:<br>
><br>
> +    ObjCInterfaceDecl* decl = cast<ObjCInterfaceType>(Ty)->getDecl();<br>
> +    if (decl)<br>
><br>
> cast<> can not return null (it will either succeed or assert in<br>
> +Asserts mode, or just produce a wrong value in -Asserts).  Use<br>
> dyn_cast (that returns null on failure) or drop the check -- whatever<br>
> is appropriate.  And there's a dyn_cast idiom:<br>
><br>
> if (Foo *F = dyn_cast<Foo>(Blah))<br>
> ... use F...<br>
<br>
</div>I'm actually not checking the return value from cast<>() but the the result of getDecl() [which just happens to also return an ObjCInterfaceDecl]. Do you think I should use a temporary for the result of the cast to make it clearer?</blockquote>
<div><br></div><div style>Then you're missing test cases, because dyn_cast doesn't propagate null. It should fail if you pass it null.<br><br>You  probably want cast_or_null. </div></div></div></div>