Author: Timm Baeder
Date: 2026-08-24T16:21:27+02:00
New Revision: 8a356a19a78e20f54a9159ebbcf97e0e23cd823a

URL: 
https://github.com/llvm/llvm-project/commit/8a356a19a78e20f54a9159ebbcf97e0e23cd823a
DIFF: 
https://github.com/llvm/llvm-project/commit/8a356a19a78e20f54a9159ebbcf97e0e23cd823a.diff

LOG: [clang][bytecode] Optimize canClassify/classify (#218397)

Always get the canonical type and handle some more builtin types in
canClassify().

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Context.cpp
    clang/lib/AST/ByteCode/Context.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Context.cpp 
b/clang/lib/AST/ByteCode/Context.cpp
index 0678b07d0bbf2..96f26a6a7a083 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -463,8 +463,9 @@ static PrimType integralTypeToPrimTypeU(unsigned BitWidth) {
 }
 
 OptPrimType Context::classify(QualType T) const {
+  T = T.getCanonicalType();
 
-  if (const auto *BT = dyn_cast<BuiltinType>(T.getCanonicalType())) {
+  if (const auto *BT = dyn_cast<BuiltinType>(T)) {
     auto Kind = BT->getKind();
     if (Kind == BuiltinType::Bool)
       return PT_Bool;
@@ -528,10 +529,7 @@ OptPrimType Context::classify(QualType T) const {
   if (const auto *AT = T->getAs<AtomicType>())
     return classify(AT->getValueType());
 
-  if (const auto *DT = dyn_cast<DecltypeType>(T))
-    return classify(DT->getUnderlyingType());
-
-  if (const auto *OBT = T.getCanonicalType()->getAs<OverflowBehaviorType>())
+  if (const auto *OBT = T->getAs<OverflowBehaviorType>())
     return classify(OBT->getUnderlyingType());
 
   if (T->isObjCObjectPointerType() || T->isBlockPointerType())

diff  --git a/clang/lib/AST/ByteCode/Context.h 
b/clang/lib/AST/ByteCode/Context.h
index eaace87ceae9d..586b600614596 100644
--- a/clang/lib/AST/ByteCode/Context.h
+++ b/clang/lib/AST/ByteCode/Context.h
@@ -131,7 +131,8 @@ class Context final {
     if (const auto *BT = dyn_cast<BuiltinType>(T)) {
       if (BT->isInteger() || BT->isFloatingPoint())
         return true;
-      if (BT->getKind() == BuiltinType::Bool)
+      if (BT->getKind() == BuiltinType::NullPtr ||
+          BT->getKind() == BuiltinType::BoundMember)
         return true;
     }
     if (T->isPointerOrReferenceType())


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to