[clang] CheckSizelessVectorOperands - use castAs<> instead of getAs<> to avoid derefe...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 25 Mar 2022 10:22:05 +0000 (10:22 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 25 Mar 2022 10:23:30 +0000 (10:23 +0000)
Move the only uses of the cast to where they are dereferenced.

clang/lib/Sema/SemaExpr.cpp

index ae48db0..1547a34 100644 (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();