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

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 4 10:18:39 PDT 2023


Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: ctetreau, tschuett.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152107

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12039,14 +12039,14 @@
     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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152107.528236.patch
Type: text/x-patch
Size: 969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230604/632df1ee/attachment.bin>


More information about the cfe-commits mailing list