[NFC][CLANG] Fix nullptr dereference issue in checkSizelessVectorShift()
authorManna, Soumi <soumi.manna@intel.com>
Mon, 5 Jun 2023 15:09:25 +0000 (08:09 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Mon, 5 Jun 2023 15:12:33 +0000 (08:12 -0700)
This patch uses castAs instead of getAs which will assert if the type doesn't match in checkSizelessVectorShift(clang::Sema &, clang::ActionResult<clang::Expr *, true> &, clang::ActionResult<clang::Expr *, true> &, clang::SourceLocation, bool).

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D152107

clang/lib/Sema/SemaExpr.cpp

index 7725806..d206278 100644 (file)
@@ -12098,14 +12098,14 @@ static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS,
     return QualType();
 
   QualType LHSType = LHS.get()->getType();
-  const BuiltinType *LHSBuiltinTy = LHSType->getAs<BuiltinType>();
+  const BuiltinType *LHSBuiltinTy = LHSType->castAs<BuiltinType>();
   QualType LHSEleType = LHSType->isVLSTBuiltinType()
                             ? LHSBuiltinTy->getSveEltType(S.getASTContext())
                             : LHSType;
 
   // Note that RHS might not be a vector
   QualType RHSType = RHS.get()->getType();
-  const BuiltinType *RHSBuiltinTy = RHSType->getAs<BuiltinType>();
+  const BuiltinType *RHSBuiltinTy = RHSType->castAs<BuiltinType>();
   QualType RHSEleType = RHSType->isVLSTBuiltinType()
                             ? RHSBuiltinTy->getSveEltType(S.getASTContext())
                             : RHSType;