From 6efede765bee15aae1258b25181421b90f78bab0 Mon Sep 17 00:00:00 2001 From: Kazu Hirata 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 +class LLVM_DEPRECATED("Use SmallPtrSet instead", "SmallPtrSet") + DeprecatedSmallSet : public SmallPtrSet {}; + template -class SmallSet : public SmallPtrSet {}; +class SmallSet : public DeprecatedSmallSet { +}; /// Equality comparison for SmallSet. ///