[clang] b6a5aea - [NFC][CLANG] Fix issue with dereference null return value in EvaluateBuiltinClassifyType()
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 28 20:12:54 PDT 2023
Author: Manna, Soumi
Date: 2023-05-28T20:09:09-07:00
New Revision: b6a5aeadb5588dedc09eacc3b98b0278d6d53529
URL: https://github.com/llvm/llvm-project/commit/b6a5aeadb5588dedc09eacc3b98b0278d6d53529
DIFF: https://github.com/llvm/llvm-project/commit/b6a5aeadb5588dedc09eacc3b98b0278d6d53529.diff
LOG: [NFC][CLANG] Fix issue with dereference null return value in EvaluateBuiltinClassifyType()
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
Added:
Modified:
clang/lib/AST/ExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 1df992cc4ce2f..f2517de4abb7d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -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;
More information about the cfe-commits
mailing list