From f64f760e2d20340ef7d1a95c8598a90e42ac31e7 Mon Sep 17 00:00:00 2001 From: "Manna, Soumi" Date: Tue, 30 May 2023 07:58:02 -0700 Subject: [PATCH] [NFC][CLANG] Fix nullptr dereference issue in Type::getSveEltType() This patch uses castAs instead of getAs which will assert if the type doesn't match in clang::Type::getSveEltType(clang::ASTContext const &) Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D151525 --- clang/lib/AST/Type.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 51e206d..508965f 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2434,7 +2434,7 @@ bool Type::isVLSTBuiltinType() const { QualType Type::getSveEltType(const ASTContext &Ctx) const { assert(isVLSTBuiltinType() && "unsupported type!"); - const BuiltinType *BTy = getAs(); + const BuiltinType *BTy = castAs(); 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 -- 2.7.4