[clang] 3581e6b - [NFC][CLANG] Fix nullptr dereference issue in checkSizelessVectorShift()

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 5 08:13:06 PDT 2023


Author: Manna, Soumi
Date: 2023-06-05T08:12:33-07:00
New Revision: 3581e6b857f44e397f61ddb35cb420347653f3ff

URL: https://github.com/llvm/llvm-project/commit/3581e6b857f44e397f61ddb35cb420347653f3ff
DIFF: https://github.com/llvm/llvm-project/commit/3581e6b857f44e397f61ddb35cb420347653f3ff.diff

LOG: [NFC][CLANG] Fix nullptr dereference issue in checkSizelessVectorShift()

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

Added: 
    

Modified: 
    clang/lib/Sema/SemaExpr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 772580674f34b..d2062786302ff 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -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;


        


More information about the cfe-commits mailing list