[NFC][CLANG] Fix issue with dereference null return value in EvaluateBuiltinClassifyT...
authorManna, Soumi <soumi.manna@intel.com>
Mon, 29 May 2023 03:08:54 +0000 (20:08 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Mon, 29 May 2023 03:09:09 +0000 (20:09 -0700)
This patch uses cast instead of dyn_cast which will assert if the type doesn't match.

Reviewed By: erichkeane

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

clang/lib/AST/ExprConstant.cpp

index 1df992c..f2517de 100644 (file)
@@ -11290,7 +11290,6 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
   assert(!T->isDependentType() && "unexpected dependent type");
 
   QualType CanTy = T.getCanonicalType();
-  const BuiltinType *BT = dyn_cast<BuiltinType>(CanTy);
 
   switch (CanTy->getTypeClass()) {
 #define TYPE(ID, BASE)
@@ -11303,7 +11302,7 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
       llvm_unreachable("unexpected non-canonical or dependent type");
 
   case Type::Builtin:
-    switch (BT->getKind()) {
+      switch (cast<BuiltinType>(CanTy)->getKind()) {
 #define BUILTIN_TYPE(ID, SINGLETON_ID)
 #define SIGNED_TYPE(ID, SINGLETON_ID) \
     case BuiltinType::ID: return GCCTypeClass::Integer;