Skip to content

Commit 9b493dc

Browse files
[ADT] Deprecate the redirection from SmallSet to SmallPtrSet (Take 2) (llvm#155078)
This patch deprecates the SmallSet specialization for pointer types, which redirects to SmallPtrSet. My previous attempt in llvm#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.
1 parent 4b23606 commit 9b493dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

llvm/include/llvm/ADT/SmallSet.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,17 @@ class SmallSet {
268268

269269
/// If this set is of pointer values, transparently switch over to using
270270
/// SmallPtrSet for performance.
271+
///
272+
/// We use this middleman class DeprecatedSmallSet so that the deprecation
273+
/// warning works. Placing LLVM_DEPRECATED just before SmallSet below won't
274+
/// work.
275+
template <typename PointeeType, unsigned N>
276+
class LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet")
277+
DeprecatedSmallSet : public SmallPtrSet<PointeeType *, N> {};
278+
271279
template <typename PointeeType, unsigned N>
272-
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {};
280+
class SmallSet<PointeeType *, N> : public DeprecatedSmallSet<PointeeType *, N> {
281+
};
273282

274283
/// Equality comparison for SmallSet.
275284
///

0 commit comments

Comments
 (0)