[llvm] [ADT] Deprecate the redirection from SmallSet to SmallPtrSet (PR #154891)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 13:07:34 PDT 2025


https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/154891

>From f60edd4bc6cf3c28144caf43c8d71146fa119256 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 19 Aug 2025 12:23:50 -0700
Subject: [PATCH 1/3] [ADT] Deprecate the redirection from SmallSet to
 SmallPtrSet

This patch deprecates the redirection from SmallSet to SmallPtrSet.

I attempted to deprecate in the usual manner:

template <typename PointeeType, unsigned N>
LLVM_DEPRECATED("...", "...")
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {};

However, the deprecation warning wouldn't fire.

For this reason, I've attached a deprecation message to the default
constructor.
---
 llvm/include/llvm/ADT/SmallSet.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index eb434bcb71717..427a89c906fd3 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -269,7 +269,13 @@ class SmallSet {
 /// If this set is of pointer values, transparently switch over to using
 /// SmallPtrSet for performance.
 template <typename PointeeType, unsigned N>
-class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {};
+class SmallSet<PointeeType *, N> : public SmallPtrSet<PointeeType *, N> {
+public:
+  // LLVM_DEPRECATED placed between "template" and "class" above won't work for
+  // some reason.  Put a deprecation message on the default constructor instead.
+  LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+  SmallSet<PointeeType *, N>() = default;
+};
 
 /// Equality comparison for SmallSet.
 ///

>From 53a4413469ca30dd1f9f7679da7e56be77dedc56 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 22 Aug 2025 11:38:49 -0700
Subject: [PATCH 2/3] Address a comment.

---
 llvm/include/llvm/ADT/SmallSet.h | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index 427a89c906fd3..a7be077fc3e5a 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -270,11 +270,27 @@ class SmallSet {
 /// SmallPtrSet for performance.
 template <typename PointeeType, unsigned N>
 class SmallSet<PointeeType *, N> : public SmallPtrSet<PointeeType *, N> {
-public:
+  using Base = SmallPtrSet<PointeeType *, N>;
+
+  public:
   // LLVM_DEPRECATED placed between "template" and "class" above won't work for
-  // some reason.  Put a deprecation message on the default constructor instead.
+  // some reason.  Put a deprecation message on constructors instead.
   LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
   SmallSet<PointeeType *, N>() = default;
+  LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+  SmallSet<PointeeType *, N>(const SmallSet &) = default;
+  LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+  SmallSet<PointeeType *, N>(SmallSet &&) = default;
+  template <typename IterT>
+  LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+  SmallSet<PointeeType *, N>(IterT Begin, IterT End) : Base(Begin, End) {}
+  template <typename Range>
+  LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+  SmallSet<PointeeType *, N>(llvm::from_range_t, Range &&R)
+      : Base(llvm::from_range, std::move(R)) {}
+  LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
+  SmallSet<PointeeType *, N>(std::initializer_list<PointeeType *> L)
+      : Base(L) {}
 };
 
 /// Equality comparison for SmallSet.

>From 4562f3dcb8c8fc2a3393b8f1aa54dd064fb5765a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 22 Aug 2025 13:07:20 -0700
Subject: [PATCH 3/3] Fix formatting.

---
 llvm/include/llvm/ADT/SmallSet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
index a7be077fc3e5a..8cd2914f7a2be 100644
--- a/llvm/include/llvm/ADT/SmallSet.h
+++ b/llvm/include/llvm/ADT/SmallSet.h
@@ -272,7 +272,7 @@ template <typename PointeeType, unsigned N>
 class SmallSet<PointeeType *, N> : public SmallPtrSet<PointeeType *, N> {
   using Base = SmallPtrSet<PointeeType *, N>;
 
-  public:
+public:
   // LLVM_DEPRECATED placed between "template" and "class" above won't work for
   // some reason.  Put a deprecation message on constructors instead.
   LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")



More information about the llvm-commits mailing list