[clang] 071d4ab - [NFC][CLANG] Fix nullptr dereference issue in HandleRISCVRVVVectorBitsTypeAttr()

via cfe-commits cfe-commits at lists.llvm.org
Wed May 31 10:02:37 PDT 2023


Author: Manna, Soumi
Date: 2023-05-31T09:58:52-07:00
New Revision: 071d4ab377d3a6f51150657c636d070e40ee2c34

URL: https://github.com/llvm/llvm-project/commit/071d4ab377d3a6f51150657c636d070e40ee2c34
DIFF: https://github.com/llvm/llvm-project/commit/071d4ab377d3a6f51150657c636d070e40ee2c34.diff

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

This patch uses castAs instead of getAs which will assert if the type doesn't match in HandleRISCVRVVVectorBitsTypeAttr(clang::QualType &, clang::ParsedAttr &, clang::Sema &)

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151769

Added: 
    

Modified: 
    clang/lib/Sema/SemaType.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 26ad4f97b0d0..1e4eecee21e5 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8340,7 +8340,7 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType,
   unsigned VecSize = static_cast<unsigned>(RVVVectorSizeInBits.getZExtValue());
 
   ASTContext::BuiltinVectorTypeInfo Info =
-      S.Context.getBuiltinVectorTypeInfo(CurType->getAs<BuiltinType>());
+      S.Context.getBuiltinVectorTypeInfo(CurType->castAs<BuiltinType>());
   unsigned EltSize = S.Context.getTypeSize(Info.ElementType);
   unsigned MinElts = Info.EC.getKnownMinValue();
 


        


More information about the cfe-commits mailing list