[NFC][CLANG] Fix nullptr dereference issue in SetValueDataBasedOnQualType()
authorManna, Soumi <soumi.manna@intel.com>
Wed, 31 May 2023 17:11:14 +0000 (10:11 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Wed, 31 May 2023 17:18:13 +0000 (10:18 -0700)
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

clang/lib/Interpreter/Interpreter.cpp

index 82d4932..4e10452 100644 (file)
@@ -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)                                                          \