Skip to content

[clang][bytecode] Reorder type checks in classify() #139046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025

Conversation

tbaederr
Copy link
Contributor

@tbaederr tbaederr commented May 8, 2025

Move the member pointer check further below and remove Complex/Vector type checks and instead rely on the final return to handle those.

Move the member pointer check further below and remove
Complex/Vector type checks and instead rely on the final return to
handle those.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels May 8, 2025
@llvmbot
Copy link
Member

llvmbot commented May 8, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

Move the member pointer check further below and remove Complex/Vector type checks and instead rely on the final return to handle those.


Full diff: https://github.com/llvm/llvm-project/pull/139046.diff

1 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Context.cpp (+6-9)
diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index db9df7abf7a29..dae94fc9829c7 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -219,10 +219,6 @@ std::optional<PrimType> Context::classify(QualType T) const {
   if (T->isBooleanType())
     return PT_Bool;
 
-  // We map these to primitive arrays.
-  if (T->isAnyComplexType() || T->isVectorType())
-    return std::nullopt;
-
   if (T->isSignedIntegerOrEnumerationType()) {
     switch (Ctx.getIntWidth(T)) {
     case 64:
@@ -259,13 +255,9 @@ std::optional<PrimType> Context::classify(QualType T) const {
   if (T->isNullPtrType())
     return PT_Ptr;
 
-  if (T->isFloatingType())
+  if (T->isRealFloatingType())
     return PT_Float;
 
-  if (T->isSpecificBuiltinType(BuiltinType::BoundMember) ||
-      T->isMemberPointerType())
-    return PT_MemberPtr;
-
   if (T->isFunctionPointerType() || T->isFunctionReferenceType() ||
       T->isFunctionType() || T->isBlockPointerType())
     return PT_Ptr;
@@ -279,9 +271,14 @@ std::optional<PrimType> Context::classify(QualType T) const {
   if (const auto *DT = dyn_cast<DecltypeType>(T))
     return classify(DT->getUnderlyingType());
 
+  if (T->isSpecificBuiltinType(BuiltinType::BoundMember) ||
+      T->isMemberPointerType())
+    return PT_MemberPtr;
+
   if (T->isFixedPointType())
     return PT_FixedPoint;
 
+  // Vector and complex types get here.
   return std::nullopt;
 }
 

@tbaederr tbaederr merged commit f7c01c4 into llvm:main May 9, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants