[clang] 5bb0692 - [NFC][CLANG] Fix nullptr dereference issue in SetValueDataBasedOnQualType()

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


Author: Manna, Soumi
Date: 2023-05-31T10:18:13-07:00
New Revision: 5bb06924657332cf35c11840c4a14acb86536fd4

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

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

This patch uses castAs instead of getAs which will assert if the type doesn't match in SetValueDataBasedOnQualType(clang::Value &, unsigned long long).

Reviewed By: erichkeane

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

Added: 
    

Modified: 
    clang/lib/Interpreter/Interpreter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 82d4932faba84..4e1045298537b 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -768,7 +768,7 @@ static void SetValueDataBasedOnQualType(Value &V, unsigned long long Data) {
   if (const auto *ET = QT->getAs<EnumType>())
     QT = ET->getDecl()->getIntegerType();
 
-  switch (QT->getAs<BuiltinType>()->getKind()) {
+  switch (QT->castAs<BuiltinType>()->getKind()) {
   default:
     llvm_unreachable("unknown type kind!");
 #define X(type, name)                                                          \


        


More information about the cfe-commits mailing list