[llvm] [llvm] replace static_assert with std::enable_if_t in ilist_node_impl (PR #127722)
Andrew Rogers via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 18 18:10:55 PST 2025
https://github.com/andrurogerz updated https://github.com/llvm/llvm-project/pull/127722
>From 28224ca715b4a7370152099303e0e6e674220500 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Tue, 18 Feb 2025 14:45:43 -0800
Subject: [PATCH 1/3] replace static_assert with std::enable_if_t
---
llvm/include/llvm/ADT/ilist_node.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/ilist_node.h b/llvm/include/llvm/ADT/ilist_node.h
index bfd50f8b3fb71..2148d6fde9be0 100644
--- a/llvm/include/llvm/ADT/ilist_node.h
+++ b/llvm/include/llvm/ADT/ilist_node.h
@@ -18,6 +18,8 @@
#include "llvm/ADT/ilist_node_base.h"
#include "llvm/ADT/ilist_node_options.h"
+#include <type_traits>
+
namespace llvm {
namespace ilist_detail {
@@ -147,9 +149,8 @@ class ilist_node_impl
///
/// This requires sentinel tracking to be explicitly enabled. Use the
/// ilist_sentinel_tracking<true> option to get this API.
+ template <typename = std::enable_if_t<OptionsT::is_sentinel_tracking_explicit>>
bool isSentinel() const {
- static_assert(OptionsT::is_sentinel_tracking_explicit,
- "Use ilist_sentinel_tracking<true> to enable isSentinel()");
return node_base_type::isSentinel();
}
};
>From 31544b68bedbfc4e52ea90e9e362bbe0dc09cc0c Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Tue, 18 Feb 2025 16:02:57 -0800
Subject: [PATCH 2/3] clang-format
---
llvm/include/llvm/ADT/ilist_node.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/ADT/ilist_node.h b/llvm/include/llvm/ADT/ilist_node.h
index 2148d6fde9be0..8b3bc8ce50aa2 100644
--- a/llvm/include/llvm/ADT/ilist_node.h
+++ b/llvm/include/llvm/ADT/ilist_node.h
@@ -149,7 +149,8 @@ class ilist_node_impl
///
/// This requires sentinel tracking to be explicitly enabled. Use the
/// ilist_sentinel_tracking<true> option to get this API.
- template <typename = std::enable_if_t<OptionsT::is_sentinel_tracking_explicit>>
+ template <
+ typename = std::enable_if_t<OptionsT::is_sentinel_tracking_explicit>>
bool isSentinel() const {
return node_base_type::isSentinel();
}
>From 30da81deb9725509bf9ee296aa1bd84b3314acd9 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Tue, 18 Feb 2025 18:10:36 -0800
Subject: [PATCH 3/3] use std::enable_if_t for the return type to compile
properly with clang
---
llvm/include/llvm/ADT/ilist_node.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/llvm/include/llvm/ADT/ilist_node.h b/llvm/include/llvm/ADT/ilist_node.h
index 8b3bc8ce50aa2..a23f00613c2a3 100644
--- a/llvm/include/llvm/ADT/ilist_node.h
+++ b/llvm/include/llvm/ADT/ilist_node.h
@@ -149,9 +149,8 @@ class ilist_node_impl
///
/// This requires sentinel tracking to be explicitly enabled. Use the
/// ilist_sentinel_tracking<true> option to get this API.
- template <
- typename = std::enable_if_t<OptionsT::is_sentinel_tracking_explicit>>
- bool isSentinel() const {
+ template <typename T = OptionsT>
+ std::enable_if_t<T::is_sentinel_tracking_explicit, bool> isSentinel() const {
return node_base_type::isSentinel();
}
};
More information about the llvm-commits
mailing list