[llvm] [ADT] Deprecate the redirection from SmallSet to SmallPtrSet (Take 2) (PR #155078)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 23 06:37:53 PDT 2025
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/155078
>From 6efede765bee15aae1258b25181421b90f78bab0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 22 Aug 2025 22:30:06 -0700
Subject: [PATCH] [ADT] Deprecate the redirection from SmallSet to SmallPtrSet
(Take 2)
This patch deprecates the SmallSet specialization for pointer types,
which redirects to SmallPtrSet.
My previous attempt in #154891 broke downstream users. Adding
user-defined constructors with LLVM_DEPRECATED inadvertently caused
the compiler to delete the copy and move assignment operators.
This iteration sidesteps the "Rule of Five" issue entirely by
introducing an intermediate class, DeprecatedSmallSet. The
deprecation attribute is attached to this new class, and SmallSet
specialization inherits from it.
---
llvm/include/llvm/ADT/SmallSet.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index eb434bcb71717..96a68fb8da0e2 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -268,8 +268,17 @@ class SmallSet {
/// If this set is of pointer values, transparently switch over to using
/// SmallPtrSet for performance.
+///
+/// We use this middleman class DeprecatedSmallSet so that the deprecation
+/// warning works. Placing LLVM_DEPRECATED just before SmallSet below won't
+/// work.
+template <typename PointeeType, unsigned N>
+class LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+ DeprecatedSmallSet : public SmallPtrSet<PointeeType *, N> {};
+
template <typename PointeeType, unsigned N>
-class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {};
+class SmallSet<PointeeType *, N> : public DeprecatedSmallSet<PointeeType *, N> {
+};
/// Equality comparison for SmallSet.
///
More information about the llvm-commits
mailing list