-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[ADT] Deprecate the redirection from SmallSet to SmallPtrSet #154891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADT] Deprecate the redirection from SmallSet to SmallPtrSet #154891
Conversation
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/pr-subscribers-llvm-adt Author: Kazu Hirata (kazutakahirata) ChangesThis patch deprecates the redirection from SmallSet to SmallPtrSet. I attempted to deprecate in the usual manner: template <typename PointeeType, unsigned N> However, the deprecation warning wouldn't fire. For this reason, I've attached a deprecation message to the default Full diff: https://github.com/llvm/llvm-project/pull/154891.diff 1 Files Affected:
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.
///
|
[[deprecated]] struct S1 {} var1; // `var1` is deprecated
struct [[deprecated]] S2 {} var2; // `S2` is deprecated |
✅ With the latest revision this PR passed the C/C++ code formatter. |
Did you try template <typename PointeeType, unsigned N>
class LLVM_DEPRECATED("...", "...") SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {}; |
@zwuis Yes, I just tried. I still don't get a warning when I intentionally place |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/15019 Here is the relevant piece of the build log for the reference
|
…#155075) Reverts #154891 The added constructors changes the semantics of other implicitly defined constructors, which causes downstream breakages. ``` ... error: object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted ... note: explicitly defaulted function was implicitly deleted here ... note: copy assignment operator of 'X' is implicitly deleted because field 'x' has a deleted copy assignment operator llvm/include/llvm/ADT/SmallSet.h:283:3: note: copy assignment operator is implicitly deleted because 'SmallSet<const XX *, 2>' has a user-declared move constructor 283 | SmallSet(SmallSet &&) = default; ```
…mallPtrSet" (#155075) Reverts llvm/llvm-project#154891 The added constructors changes the semantics of other implicitly defined constructors, which causes downstream breakages. ``` ... error: object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted ... note: explicitly defaulted function was implicitly deleted here ... note: copy assignment operator of 'X' is implicitly deleted because field 'x' has a deleted copy assignment operator llvm/include/llvm/ADT/SmallSet.h:283:3: note: copy assignment operator is implicitly deleted because 'SmallSet<const XX *, 2>' has a user-declared move constructor 283 | SmallSet(SmallSet &&) = default; ```
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.
…#155078) 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.
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.