[PATCH] D151525: [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType()

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 25 18:48:16 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 clang::​Type::​getSveEltType(clang::​ASTContext const &)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151525

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2421,7 +2421,7 @@
 QualType Type::getSveEltType(const ASTContext &Ctx) const {
   assert(isVLSTBuiltinType() && "unsupported type!");
 
-  const BuiltinType *BTy = getAs<BuiltinType>();
+  const BuiltinType *BTy = castAs<BuiltinType>();
   if (BTy->getKind() == BuiltinType::SveBool)
     // Represent predicates as i8 rather than i1 to avoid any layout issues.
     // The type is bitcasted to a scalable predicate type when casting between


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151525.525906.patch
Type: text/x-patch
Size: 598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230526/da0f040d/attachment.bin>


More information about the cfe-commits mailing list