Skip to content

Commit

Permalink
[NFC][CLANG] Fix issue with dereference null return value in Evaluate…
Browse files Browse the repository at this point in the history
…BuiltinClassifyType()

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
  • Loading branch information
smanna12 committed May 29, 2023
1 parent fbb241c commit b6a5aea
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit b6a5aea

Please sign in to comment.