On Mon, Feb 18, 2013 at 4:24 PM, Adrian Prantl <apra...@apple.com> wrote:
> > On Feb 15, 2013, at 3:59 PM, Dmitri Gribenko <griboz...@gmail.com> wrote: > > > > + ObjCInterfaceDecl* decl = cast<ObjCInterfaceType>(Ty)->getDecl(); > > + if (decl) > > > > cast<> can not return null (it will either succeed or assert in > > +Asserts mode, or just produce a wrong value in -Asserts). Use > > dyn_cast (that returns null on failure) or drop the check -- whatever > > is appropriate. And there's a dyn_cast idiom: > > > > if (Foo *F = dyn_cast<Foo>(Blah)) > > ... use F... > > 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? Then you're missing test cases, because dyn_cast doesn't propagate null. It should fail if you pass it null. You probably want cast_or_null.
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits