Skip to content

[clang][NFC] Use BuiltinType::isFloatingPoint() in Type::isFloatingType() #139035

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

They both used to do the same comparison of getKind() to Half and Ibm128.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 8, 2025
@llvmbot
Copy link
Member

llvmbot commented May 8, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

They both used to do the same comparison of getKind() to Half and Ibm128.


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

1 Files Affected:

  • (modified) clang/lib/AST/Type.cpp (+1-2)
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 392a95d042353..82ca2c62eba30 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2301,8 +2301,7 @@ bool Type::hasUnsignedIntegerRepresentation() const {
 
 bool Type::isFloatingType() const {
   if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
-    return BT->getKind() >= BuiltinType::Half &&
-           BT->getKind() <= BuiltinType::Ibm128;
+    return BT->isFloatingPoint();
   if (const auto *CT = dyn_cast<ComplexType>(CanonicalType))
     return CT->getElementType()->isFloatingType();
   return false;

They both used to do the same comparison of getKind() to Half and
Ibm128.
@tbaederr tbaederr force-pushed the is-floating-point branch from c114d0f to 39af196 Compare May 8, 2025 07:44
@tbaederr
Copy link
Contributor Author

tbaederr commented May 8, 2025

I considered that the comparison is inlined in isFloatingType for performance reasons, but the git log doesn't suggest anything like that.

@tbaederr tbaederr merged commit c0f5b0a into llvm:main May 9, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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