[llvm] r235463 - [TableGen] Use cast instead of dyn_cast where result isn't checked before being dereferenced.

Craig Topper craig.topper at gmail.com
Tue Apr 21 19:54:55 PDT 2015


Actually it turns out I just misread the parentheses and what the cast
applies to. Oops! Though I think getDefInit always makes a type object in
the record. I'll revert until I figure it out.

On Tue, Apr 21, 2015 at 7:40 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Tue, Apr 21, 2015 at 7:09 PM, Craig Topper <craig.topper at gmail.com>
> wrote:
> > Author: ctopper
> > Date: Tue Apr 21 21:09:42 2015
> > New Revision: 235463
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=235463&view=rev
> > Log:
> > [TableGen] Use cast instead of dyn_cast where result isn't checked
> before being dereferenced.
> >
> > Modified:
> >     llvm/trunk/lib/TableGen/Record.cpp
> >
> > Modified: llvm/trunk/lib/TableGen/Record.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=235463&r1=235462&r2=235463&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/TableGen/Record.cpp (original)
> > +++ llvm/trunk/lib/TableGen/Record.cpp Tue Apr 21 21:09:42 2015
> > @@ -345,7 +345,7 @@ Init *DagRecTy::convertValue(BinOpInit *
> >  }
> >
> >  RecordRecTy *RecordRecTy::get(Record *R) {
> > -  return dyn_cast<RecordRecTy>(R->getDefInit()->getType());
> > +  return cast<RecordRecTy>(R->getDefInit()->getType());
>
> Is it? Callers could still check this for null? (perhaps you already
> checked that none of the callers check this for null/)
>
> >  }
> >
> >  std::string RecordRecTy::getAsString() const {
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150421/5c477672/attachment.html>


More information about the llvm-commits mailing list