[PATCH] D152197: [NFC][CLANG] Fix static analyzer bugs with dereference after null check

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 5 13:44:32 PDT 2023


Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added subscribers: ctetreau, manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.
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 clang::​Sema::​CheckSizelessVectorOperands(clang::​ActionResult<clang::​Expr *, true> &, clang::​ActionResult<clang::​Expr *, true> &, clang::​SourceLocation, bool, clang::​Sema::​ArithConvKind).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152197

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11111,8 +11111,8 @@
   QualType LHSType = LHS.get()->getType().getUnqualifiedType();
   QualType RHSType = RHS.get()->getType().getUnqualifiedType();
 
-  const BuiltinType *LHSBuiltinTy = LHSType->getAs<BuiltinType>();
-  const BuiltinType *RHSBuiltinTy = RHSType->getAs<BuiltinType>();
+  const BuiltinType *LHSBuiltinTy = LHSType->castAs<BuiltinType>();
+  const BuiltinType *RHSBuiltinTy = RHSType->castAs<BuiltinType>();
 
   unsigned DiagID = diag::err_typecheck_invalid_operands;
   if ((OperationKind == ACK_Arithmetic) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152197.528566.patch
Type: text/x-patch
Size: 702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230605/2731fadb/attachment.bin>


More information about the cfe-commits mailing list