From 28224ca715b4a7370152099303e0e6e674220500 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 18 Feb 2025 14:45:43 -0800 Subject: [PATCH 1/4] 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 + 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 option to get this API. + template > bool isSentinel() const { - static_assert(OptionsT::is_sentinel_tracking_explicit, - "Use ilist_sentinel_tracking to enable isSentinel()"); return node_base_type::isSentinel(); } }; From 31544b68bedbfc4e52ea90e9e362bbe0dc09cc0c Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 18 Feb 2025 16:02:57 -0800 Subject: [PATCH 2/4] 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 option to get this API. - template > + template < + typename = std::enable_if_t> bool isSentinel() const { return node_base_type::isSentinel(); } From 30da81deb9725509bf9ee296aa1bd84b3314acd9 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 18 Feb 2025 18:10:36 -0800 Subject: [PATCH 3/4] 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 option to get this API. - template < - typename = std::enable_if_t> - bool isSentinel() const { + template + std::enable_if_t isSentinel() const { return node_base_type::isSentinel(); } }; From 00ea38992441cdd65c23bcc6af2bc38e3f934f86 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 19 Feb 2025 09:53:10 -0800 Subject: [PATCH 4/4] add a comment explainin why std::enable_if is used on this method --- llvm/include/llvm/ADT/ilist_node.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/include/llvm/ADT/ilist_node.h b/llvm/include/llvm/ADT/ilist_node.h index a23f00613c2a3..67384546a9275 100644 --- a/llvm/include/llvm/ADT/ilist_node.h +++ b/llvm/include/llvm/ADT/ilist_node.h @@ -149,6 +149,11 @@ class ilist_node_impl /// /// This requires sentinel tracking to be explicitly enabled. Use the /// ilist_sentinel_tracking option to get this API. + /// + /// Rather than using static_assert to enforce the API is not called when + /// configured with is_sentinel_tracking_explicit=false, the method is + /// conditionally provided using std::enable_if. This way, clients of + /// ilist_node_impl can be fully instantiated for DLLExport on Windows. template std::enable_if_t isSentinel() const { return node_base_type::isSentinel();