[clang] CheckSizelessVectorOperands - use castAs<> instead of getAs<> to avoid dereference of nullptr

Move the only uses of the cast to where they are dereferenced.
This commit is contained in:
Simon Pilgrim 2022-03-25 10:22:05 +00:00
parent 19de2a5768
commit ce2b36e123
1 changed files with 2 additions and 4 deletions

View File

@ -10490,12 +10490,10 @@ QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
QualType LHSType = LHS.get()->getType().getUnqualifiedType();
QualType RHSType = RHS.get()->getType().getUnqualifiedType();
const BuiltinType *LHSVecType = LHSType->getAs<BuiltinType>();
const BuiltinType *RHSVecType = RHSType->getAs<BuiltinType>();
unsigned DiagID = diag::err_typecheck_invalid_operands;
if ((OperationKind == ACK_Arithmetic) &&
(LHSVecType->isSVEBool() || RHSVecType->isSVEBool())) {
(LHSType->castAs<BuiltinType>()->isSVEBool() ||
RHSType->castAs<BuiltinType>()->isSVEBool())) {
Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
<< RHS.get()->getSourceRange();
return QualType();