[clang] b0525f6 - [NFC][CLANG] [NFC][CLANG] Fix nullptr dereference issue in ConvertQualTypeToKind()

via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 4 09:41:11 PDT 2023


Author: Manna, Soumi
Date: 2023-06-04T09:35:44-07:00
New Revision: b0525f66988eac69138ba4ca30f5f07ff5218093

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

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

This patch uses castAs instead of getAs which will assert if the type doesn't match in ConvertQualTypeToKind(clang::ASTContext const &, clang::QualType).

Reviewed By: erichkeane

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

Added: 
    

Modified: 
    clang/lib/Interpreter/Value.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Interpreter/Value.cpp b/clang/lib/Interpreter/Value.cpp
index fe37eebac5257..6d0eaf1b82e10 100644
--- a/clang/lib/Interpreter/Value.cpp
+++ b/clang/lib/Interpreter/Value.cpp
@@ -108,7 +108,7 @@ static Value::Kind ConvertQualTypeToKind(const ASTContext &Ctx, QualType QT) {
   if (!BT || BT->isNullPtrType())
     return Value::K_PtrOrObj;
 
-  switch (QT->getAs<BuiltinType>()->getKind()) {
+  switch (QT->castAs<BuiltinType>()->getKind()) {
   default:
     assert(false && "Type not supported");
     return Value::K_Unspecified;


        


More information about the cfe-commits mailing list