[llvm] 133ac3a - [ADT] Achieve the "Rule of Zero" in DGNode (#165190)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 26 22:09:45 PDT 2025
Author: Kazu Hirata
Date: 2025-10-26T22:09:40-07:00
New Revision: 133ac3ad3fe87f9b3c21748d3421e65977605756
URL: https://github.com/llvm/llvm-project/commit/133ac3ad3fe87f9b3c21748d3421e65977605756
DIFF: https://github.com/llvm/llvm-project/commit/133ac3ad3fe87f9b3c21748d3421e65977605756.diff
LOG: [ADT] Achieve the "Rule of Zero" in DGNode (#165190)
This patch achieves the "Rule of Zero" in DGNode by removing the
copy/move constructors and copy/move assignment operators.
Note that the code being deleted does a couple of unusual things that
are most likely oversight:
- The copy constructor with "explicit" is highly unusual. This means
that we allow "DGNode<N, E> A(B);" but disallow
"DGNode<N, E> A = B;".
- The move assignment operator with const r-value reference is also
unusual, especially given that the move constructor is correctly
implemented.
Added:
Modified:
llvm/include/llvm/ADT/DirectedGraph.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/DirectedGraph.h b/llvm/include/llvm/ADT/DirectedGraph.h
index fb6b180f77e6b..fe7c9e51cbd9a 100644
--- a/llvm/include/llvm/ADT/DirectedGraph.h
+++ b/llvm/include/llvm/ADT/DirectedGraph.h
@@ -80,18 +80,6 @@ template <class NodeType, class EdgeType> class DGNode {
explicit DGNode(EdgeType &E) : Edges() { Edges.insert(&E); }
DGNode() = default;
- explicit DGNode(const DGNode<NodeType, EdgeType> &N) : Edges(N.Edges) {}
- DGNode(DGNode<NodeType, EdgeType> &&N) : Edges(std::move(N.Edges)) {}
-
- DGNode<NodeType, EdgeType> &operator=(const DGNode<NodeType, EdgeType> &N) {
- Edges = N.Edges;
- return *this;
- }
- DGNode<NodeType, EdgeType> &operator=(const DGNode<NodeType, EdgeType> &&N) {
- Edges = std::move(N.Edges);
- return *this;
- }
-
/// Static polymorphism: delegate implementation (via isEqualTo) to the
/// derived class.
friend bool operator==(const NodeType &M, const NodeType &N) {
More information about the llvm-commits
mailing list