From b2afd576125307af2918fa4f3e2cd9340a651d69 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 1 Oct 2025 08:17:12 -0700 Subject: [PATCH 1/2] [ADT] Use "= default" in DirectedGraph.h This patch uses "= default" in copy/move constructors and assignment operators of DirectedGraph. 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. --- llvm/include/llvm/ADT/DirectedGraph.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/ADT/DirectedGraph.h b/llvm/include/llvm/ADT/DirectedGraph.h index 83c0bea6393c4..2a51bc631399c 100644 --- a/llvm/include/llvm/ADT/DirectedGraph.h +++ b/llvm/include/llvm/ADT/DirectedGraph.h @@ -181,16 +181,10 @@ template 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; - } + DirectedGraph(const DGraphType &G) = default; + DirectedGraph(DGraphType &&RHS) = default; + DGraphType &operator=(const DGraphType &G) = default; + DGraphType &operator=(DGraphType &&G) = default; const_iterator begin() const { return Nodes.begin(); } const_iterator end() const { return Nodes.end(); } From 9db20de6d080eae34bbeedc7a5456ea55c423ba9 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 2 Oct 2025 08:09:07 -0700 Subject: [PATCH 2/2] Address a comment. --- llvm/include/llvm/ADT/DirectedGraph.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/llvm/include/llvm/ADT/DirectedGraph.h b/llvm/include/llvm/ADT/DirectedGraph.h index 2a51bc631399c..fb6b180f77e6b 100644 --- a/llvm/include/llvm/ADT/DirectedGraph.h +++ b/llvm/include/llvm/ADT/DirectedGraph.h @@ -181,10 +181,6 @@ template class DirectedGraph { DirectedGraph() = default; explicit DirectedGraph(NodeType &N) : Nodes() { addNode(N); } - DirectedGraph(const DGraphType &G) = default; - DirectedGraph(DGraphType &&RHS) = default; - DGraphType &operator=(const DGraphType &G) = default; - DGraphType &operator=(DGraphType &&G) = default; const_iterator begin() const { return Nodes.begin(); } const_iterator end() const { return Nodes.end(); }