Skip to content

Commit 3985d8f

Browse files
[Support] Use "if constexpr" in shouldReverseIterate
This patch simplifies shouldReverseIterate with "if constexpr" while switching to "constexpr bool", allowing compile-time evaluation at call sites.
1 parent 9971844 commit 3985d8f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

llvm/include/llvm/Support/ReverseIteration.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
namespace llvm {
88

9-
template<class T = void *>
10-
bool shouldReverseIterate() {
11-
#if LLVM_ENABLE_REVERSE_ITERATION
12-
return detail::IsPointerLike<T>::value;
13-
#else
14-
return false;
15-
#endif
9+
template <class T = void *> constexpr bool shouldReverseIterate() {
10+
if constexpr (LLVM_ENABLE_REVERSE_ITERATION)
11+
return detail::IsPointerLike<T>::value;
12+
else
13+
return false;
1614
}
1715

1816
} // namespace llvm

0 commit comments

Comments
 (0)