[clang] VisitCastExpr - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is always dereferenced, so assert the cast is correct (which it should be as we just created that ScalableVectorType) instead of returning nullptr
This commit is contained in:
Simon Pilgrim 2022-02-11 10:51:34 +00:00
parent a5d6851489
commit 9ece72c159
1 changed files with 2 additions and 2 deletions

View File

@ -2093,7 +2093,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
if (ScalableDst == PredType &&
FixedSrc->getElementType() == Builder.getInt8Ty()) {
DstTy = llvm::ScalableVectorType::get(Builder.getInt8Ty(), 2);
ScalableDst = dyn_cast<llvm::ScalableVectorType>(DstTy);
ScalableDst = cast<llvm::ScalableVectorType>(DstTy);
NeedsBitCast = true;
}
if (FixedSrc->getElementType() == ScalableDst->getElementType()) {
@ -2119,7 +2119,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
if (ScalableSrc == PredType &&
FixedDst->getElementType() == Builder.getInt8Ty()) {
SrcTy = llvm::ScalableVectorType::get(Builder.getInt8Ty(), 2);
ScalableSrc = dyn_cast<llvm::ScalableVectorType>(SrcTy);
ScalableSrc = cast<llvm::ScalableVectorType>(SrcTy);
Src = Builder.CreateBitCast(Src, SrcTy);
}
if (ScalableSrc->getElementType() == FixedDst->getElementType()) {