[llvm] 7eb5c08 - [ADT] Use "= default" in DirectedGraph.h (#161628)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 2 09:27:14 PDT 2025
Author: Kazu Hirata
Date: 2025-10-02T09:27:09-07:00
New Revision: 7eb5c08ac3a5bc524a5fe4e2e91db3a5b1ffe3cd
URL: https://github.com/llvm/llvm-project/commit/7eb5c08ac3a5bc524a5fe4e2e91db3a5b1ffe3cd
DIFF: https://github.com/llvm/llvm-project/commit/7eb5c08ac3a5bc524a5fe4e2e91db3a5b1ffe3cd.diff
LOG: [ADT] Use "= default" in DirectedGraph.h (#161628)
This patch drops user copy/move constructors and assignment operators
of DirectedGraph to adhere to the Rule of Zero.
Now, the original code:
DGraphType &operator=(const DGraphType &&G)
is most likely unintended -- a move assignment operator with const
r-value reference. This patch fixes that.
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 83c0bea6393c4..fb6b180f77e6b 100644
--- a/llvm/include/llvm/ADT/DirectedGraph.h
+++ b/llvm/include/llvm/ADT/DirectedGraph.h
@@ -181,16 +181,6 @@ template <class NodeType, class EdgeType> class DirectedGraph {
DirectedGraph() = default;
explicit DirectedGraph(NodeType &N) : Nodes() { addNode(N); }
- DirectedGraph(const DGraphType &G) : Nodes(G.Nodes) {}
- DirectedGraph(DGraphType &&RHS) : Nodes(std::move(RHS.Nodes)) {}
- DGraphType &operator=(const DGraphType &G) {
- Nodes = G.Nodes;
- return *this;
- }
- DGraphType &operator=(const DGraphType &&G) {
- Nodes = std::move(G.Nodes);
- return *this;
- }
const_iterator begin() const { return Nodes.begin(); }
const_iterator end() const { return Nodes.end(); }
More information about the llvm-commits
mailing list