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

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 19:26:45 PDT 2023


Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151770

Files:
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===================================================================
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -768,7 +768,7 @@
   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)                                                          \


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151770.526871.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230531/f8649da3/attachment-0001.bin>


More information about the cfe-commits mailing list