Skip to content

Conversation

kazutakahirata
Copy link
Contributor

@kazutakahirata kazutakahirata commented Sep 16, 2025

This patch simplifies replaces TypeIsArrayType. If
std::is_same<ArrayType, ArrayType> is true, then
std::is_base_of<ArrayType, ArrayType> must also be true, so
std::is_base_of<ArrayType, ArrayType> alone is sufficient.

This patch replaces, std::integral_constant<bool, ...> with
std::bool_constant for brevity.  Note that std::bool_constant was
introduced as part of C++17.

While I am at it, this patch uses the "_v" variants of type traits.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Sep 16, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 16, 2025

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

Changes

This patch replaces, std::integral_constant<bool, ...> with
std::bool_constant for brevity. Note that std::bool_constant was
introduced as part of C++17.

While I am at it, this patch uses the "_v" variants of type traits.


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

1 Files Affected:

  • (modified) clang/include/clang/AST/TypeBase.h (+2-3)
diff --git a/clang/include/clang/AST/TypeBase.h b/clang/include/clang/AST/TypeBase.h
index 9074992a3de8c..3725cd98394fb 100644
--- a/clang/include/clang/AST/TypeBase.h
+++ b/clang/include/clang/AST/TypeBase.h
@@ -9093,9 +9093,8 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
 // Helper class template that is used by Type::getAs to ensure that one does
 // not try to look through a qualified type to get to an array type.
 template <typename T>
-using TypeIsArrayType =
-    std::integral_constant<bool, std::is_same<T, ArrayType>::value ||
-                                     std::is_base_of<ArrayType, T>::value>;
+using TypeIsArrayType = std::bool_constant<std::is_same_v<T, ArrayType> ||
+                                           std::is_base_of_v<ArrayType, T>>;
 
 // Member-template getAs<specific type>'.
 template <typename T> const T *Type::getAs() const {

@kazutakahirata kazutakahirata changed the title [AST] Use std::bool_constant instead of std::integral_constant (NFC) [AST] Simplify TypeIsArrayType (NFC) Sep 16, 2025
@kazutakahirata kazutakahirata merged commit b27bb09 into llvm:main Sep 16, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250915_AST_bool_constant branch September 16, 2025 16:07
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.

5 participants