[llvm] [ADT] Simplify IsSizeLessThanThreshold (NFC) (PR #160642)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 24 21:50:30 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/160642
IsSizeLessThanThreshold is used only in AdjustedParamTBase, just a few
lines below the declaration. This patch simplifies
IsSizeLessThanThreshold by substituting U with T, stripping away the
template, and switching to "static constexpr bool.
>From fadd8ace81b03e28e1d8c5fcef0e9601dcc431a9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 23 Sep 2025 23:27:54 -0700
Subject: [PATCH] [ADT] Simplify IsSizeLessThanThreshold (NFC)
IsSizeLessThanThreshold is used only in AdjustedParamTBase, just a few
lines below the declaration. This patch simplifies
IsSizeLessThanThreshold by substituting U with T, stripping away the
template, and switching to "static constexpr bool.
---
llvm/include/llvm/ADT/FunctionExtras.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 12a2dc36e1af0..2498cb7796f1f 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -90,13 +90,12 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
template <typename T> struct AdjustedParamTBase {
static_assert(!std::is_reference<T>::value,
"references should be handled by template specialization");
- template <typename U>
- using IsSizeLessThanThresholdT =
- std::bool_constant<sizeof(U) <= 2 * sizeof(void *)>;
+ static constexpr bool IsSizeLessThanThreshold =
+ sizeof(T) <= 2 * sizeof(void *);
using type =
std::conditional_t<std::is_trivially_copy_constructible<T>::value &&
std::is_trivially_move_constructible<T>::value &&
- IsSizeLessThanThresholdT<T>::value,
+ IsSizeLessThanThreshold,
T, T &>;
};
More information about the llvm-commits
mailing list