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

David Blaikie dblaikie at gmail.com
Tue Apr 21 19:40:42 PDT 2015


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



More information about the llvm-commits mailing list