From 3f9e6fb72bd1b20b67e61ed97de501773a33cc08 Mon Sep 17 00:00:00 2001
From: Matt Liberty <mliberty@precisioninno.com>
Date: Wed, 25 Dec 2024 05:57:55 +0000
Subject: [PATCH] par: fix clang-tidy misc-include-cleaner

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
---
 src/par/include/par/PartitionMgr.h |  4 ++--
 src/par/src/Coarsener.cpp          | 14 +++++++-----
 src/par/src/Coarsener.h            |  5 +++++
 src/par/src/Evaluator.cpp          | 12 ++++++++++
 src/par/src/Evaluator.h            |  7 ++++--
 src/par/src/GreedyRefine.cpp       |  9 ++++++++
 src/par/src/GreedyRefine.h         |  6 ++++-
 src/par/src/Hypergraph.cpp         |  6 +++--
 src/par/src/Hypergraph.h           |  4 ++--
 src/par/src/ILPRefine.cpp          | 10 +++++++++
 src/par/src/ILPRefine.h            |  6 ++++-
 src/par/src/KWayFMRefine.cpp       | 13 +++++++++++
 src/par/src/KWayFMRefine.h         |  7 +++++-
 src/par/src/KWayPMRefine.cpp       | 13 +++++++++++
 src/par/src/KWayPMRefine.h         |  9 +++++++-
 src/par/src/MakePartitionMgr.cpp   |  1 -
 src/par/src/Multilevel.cpp         | 12 ++++++++++
 src/par/src/Multilevel.h           |  3 +++
 src/par/src/PartitionMgr.cpp       | 11 ++++++++--
 src/par/src/Partitioner.cpp        |  6 +++++
 src/par/src/Partitioner.h          |  3 +++
 src/par/src/PriorityQueue.cpp      |  5 +++++
 src/par/src/PriorityQueue.h        |  7 +++++-
 src/par/src/Refiner.cpp            |  6 +++++
 src/par/src/Refiner.h              |  5 ++++-
 src/par/src/TritonPart.cpp         | 35 ++++++++++++++++++------------
 src/par/src/TritonPart.h           | 11 ++--------
 src/par/src/Utilities.cpp          | 15 ++-----------
 28 files changed, 186 insertions(+), 59 deletions(-)

diff --git a/src/par/include/par/PartitionMgr.h b/src/par/include/par/PartitionMgr.h
index dc1d73ad57f..cb9277615a6 100644
--- a/src/par/include/par/PartitionMgr.h
+++ b/src/par/include/par/PartitionMgr.h
@@ -36,9 +36,9 @@
 #pragma once
 
 #include <map>
-#include <memory>
-#include <random>
 #include <set>
+#include <string>
+#include <vector>
 
 namespace ord {
 class dbVerilogNetwork;
diff --git a/src/par/src/Coarsener.cpp b/src/par/src/Coarsener.cpp
index 29d9bbb1d45..2b2ceab7e06 100644
--- a/src/par/src/Coarsener.cpp
+++ b/src/par/src/Coarsener.cpp
@@ -40,9 +40,17 @@
 
 #include "Coarsener.h"
 
+#include <algorithm>
+#include <chrono>
+#include <cstdlib>
+#include <limits>
+#include <map>
+#include <memory>
 #include <numeric>
 #include <random>
 #include <set>
+#include <utility>
+#include <vector>
 
 #include "Evaluator.h"
 #include "Hypergraph.h"
@@ -511,12 +519,6 @@ void Coarsener::VertexMatching(
         = hgraph->GetNumVertices() + cluster_id - num_visited_vertices;
     // check the early-stop condition
     if (remaining_vertices <= num_early_stop_visited_vertices) {
-      int num_visited_vertices_new = 0;
-      for (auto flag_new : vertex_cluster_id_vec) {
-        if (flag_new > -1) {
-          num_visited_vertices_new++;
-        }
-      }
       v_iter++;
       while (v_iter != unvisited.end()) {
         const int cur_vertex = *v_iter;
diff --git a/src/par/src/Coarsener.h b/src/par/src/Coarsener.h
index 48a365f2803..add9cc82a1c 100644
--- a/src/par/src/Coarsener.h
+++ b/src/par/src/Coarsener.h
@@ -40,8 +40,13 @@
 // It will accept a HGraphPtr (std::shared_ptr<Hypergraph>) as input
 // and return a sequence of coarser hypergraphs
 
+#include <memory>
+#include <string>
+#include <vector>
+
 #include "Evaluator.h"
 #include "Hypergraph.h"
+#include "Utilities.h"
 #include "utl/Logger.h"
 
 namespace par {
diff --git a/src/par/src/Evaluator.cpp b/src/par/src/Evaluator.cpp
index affe21b617e..ff43de97e46 100644
--- a/src/par/src/Evaluator.cpp
+++ b/src/par/src/Evaluator.cpp
@@ -34,9 +34,21 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "Evaluator.h"
 
+#include <algorithm>
+#include <boost/range/iterator_range_core.hpp>
+#include <cmath>
 #include <fstream>
 #include <functional>
+#include <iomanip>
+#include <ios>
+#include <limits>
+#include <map>
 #include <numeric>
+#include <ostream>
+#include <sstream>
+#include <string>
+#include <utility>
+#include <vector>
 
 #include "Hypergraph.h"
 #include "Utilities.h"
diff --git a/src/par/src/Evaluator.h b/src/par/src/Evaluator.h
index a9e1d9eb4a4..d910e6480fd 100644
--- a/src/par/src/Evaluator.h
+++ b/src/par/src/Evaluator.h
@@ -34,8 +34,11 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
-#include <tuple>
+#include <map>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
 
 #include "Hypergraph.h"
 #include "Utilities.h"
diff --git a/src/par/src/GreedyRefine.cpp b/src/par/src/GreedyRefine.cpp
index 760ecf448fb..c6039efc7e0 100644
--- a/src/par/src/GreedyRefine.cpp
+++ b/src/par/src/GreedyRefine.cpp
@@ -34,6 +34,15 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "GreedyRefine.h"
 
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "Evaluator.h"
+#include "Hypergraph.h"
+#include "Refiner.h"
+#include "Utilities.h"
+
 // ------------------------------------------------------------------------------
 // K-way hyperedge greedy refinement
 // ------------------------------------------------------------------------------
diff --git a/src/par/src/GreedyRefine.h b/src/par/src/GreedyRefine.h
index 8498c9d056e..a5501c119a2 100644
--- a/src/par/src/GreedyRefine.h
+++ b/src/par/src/GreedyRefine.h
@@ -34,9 +34,13 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
+#include <memory>
+#include <vector>
 
+#include "Evaluator.h"
+#include "Hypergraph.h"
 #include "Refiner.h"
+#include "Utilities.h"
 
 namespace par {
 
diff --git a/src/par/src/Hypergraph.cpp b/src/par/src/Hypergraph.cpp
index 47d1ec7a205..20d113c3b4f 100644
--- a/src/par/src/Hypergraph.cpp
+++ b/src/par/src/Hypergraph.cpp
@@ -35,8 +35,10 @@
 
 #include "Hypergraph.h"
 
-#include <iostream>
-#include <string>
+#include <algorithm>
+#include <limits>
+#include <set>
+#include <vector>
 
 #include "Utilities.h"
 #include "utl/Logger.h"
diff --git a/src/par/src/Hypergraph.h b/src/par/src/Hypergraph.h
index 38c09c2ead8..111476a2b3c 100644
--- a/src/par/src/Hypergraph.h
+++ b/src/par/src/Hypergraph.h
@@ -43,8 +43,8 @@
 // Rule2 : Each hyperedge can include a vertex at most once.
 ////////////////////////////////////////////////////////////////////////////////
 #pragma once
-#include <boost/range/iterator_range.hpp>
-#include <functional>
+#include <boost/range/iterator_range_core.hpp>
+#include <memory>
 #include <set>
 #include <vector>
 
diff --git a/src/par/src/ILPRefine.cpp b/src/par/src/ILPRefine.cpp
index a597bcd1317..a061d648e83 100644
--- a/src/par/src/ILPRefine.cpp
+++ b/src/par/src/ILPRefine.cpp
@@ -34,6 +34,16 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "ILPRefine.h"
 
+#include <map>
+#include <set>
+#include <vector>
+
+#include "Evaluator.h"
+#include "Hypergraph.h"
+#include "Refiner.h"
+#include "Utilities.h"
+#include "utl/Logger.h"
+
 // ------------------------------------------------------------------------------
 // ILP-based refinement
 // ILP-based hypergraph partitioning cannot optimize path cost
diff --git a/src/par/src/ILPRefine.h b/src/par/src/ILPRefine.h
index 292f4971ffd..13841e3dd8c 100644
--- a/src/par/src/ILPRefine.h
+++ b/src/par/src/ILPRefine.h
@@ -34,9 +34,13 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
+#include <memory>
+#include <vector>
 
+#include "Evaluator.h"
+#include "Hypergraph.h"
 #include "Refiner.h"
+#include "Utilities.h"
 
 namespace par {
 
diff --git a/src/par/src/KWayFMRefine.cpp b/src/par/src/KWayFMRefine.cpp
index dd20acb2cb9..be0f31ff974 100644
--- a/src/par/src/KWayFMRefine.cpp
+++ b/src/par/src/KWayFMRefine.cpp
@@ -34,7 +34,20 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "KWayFMRefine.h"
 
+#include <functional>
+#include <limits>
+#include <memory>
+#include <set>
 #include <thread>
+#include <utility>
+#include <vector>
+
+#include "Evaluator.h"
+#include "Hypergraph.h"
+#include "PriorityQueue.h"
+#include "Refiner.h"
+#include "Utilities.h"
+#include "utl/Logger.h"
 
 // Implement the direct k-way FM refinement
 namespace par {
diff --git a/src/par/src/KWayFMRefine.h b/src/par/src/KWayFMRefine.h
index 38c8a67805c..11239b1cd0f 100644
--- a/src/par/src/KWayFMRefine.h
+++ b/src/par/src/KWayFMRefine.h
@@ -34,9 +34,14 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
+#include <memory>
+#include <vector>
 
+#include "Evaluator.h"
+#include "Hypergraph.h"
 #include "Refiner.h"
+#include "Utilities.h"
+#include "utl/Logger.h"
 
 namespace par {
 
diff --git a/src/par/src/KWayPMRefine.cpp b/src/par/src/KWayPMRefine.cpp
index ffa94815f64..b7ed7e2323c 100644
--- a/src/par/src/KWayPMRefine.cpp
+++ b/src/par/src/KWayPMRefine.cpp
@@ -34,7 +34,20 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "KWayPMRefine.h"
 
+#include <algorithm>
+#include <functional>
+#include <map>
+#include <memory>
 #include <thread>
+#include <utility>
+#include <vector>
+
+#include "Evaluator.h"
+#include "Hypergraph.h"
+#include "KWayFMRefine.h"
+#include "PriorityQueue.h"
+#include "Refiner.h"
+#include "Utilities.h"
 
 // ------------------------------------------------------------------------------
 // K-way pair-wise FM refinement
diff --git a/src/par/src/KWayPMRefine.h b/src/par/src/KWayPMRefine.h
index c6d2ef69f05..5019b54604a 100644
--- a/src/par/src/KWayPMRefine.h
+++ b/src/par/src/KWayPMRefine.h
@@ -34,9 +34,16 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
+#include <map>
+#include <memory>
+#include <utility>
+#include <vector>
 
+#include "Evaluator.h"
+#include "Hypergraph.h"
 #include "KWayFMRefine.h"
+#include "Refiner.h"
+#include "Utilities.h"
 
 namespace par {
 
diff --git a/src/par/src/MakePartitionMgr.cpp b/src/par/src/MakePartitionMgr.cpp
index 3cf6c606f56..d4e6519eaf2 100644
--- a/src/par/src/MakePartitionMgr.cpp
+++ b/src/par/src/MakePartitionMgr.cpp
@@ -35,7 +35,6 @@
 
 #include "par/MakePartitionMgr.h"
 
-#include "odb/db.h"
 #include "ord/OpenRoad.hh"
 #include "par/PartitionMgr.h"
 #include "sta/StaMain.hh"
diff --git a/src/par/src/Multilevel.cpp b/src/par/src/Multilevel.cpp
index 3bf40a8d059..ef96b7251b2 100644
--- a/src/par/src/Multilevel.cpp
+++ b/src/par/src/Multilevel.cpp
@@ -35,14 +35,26 @@
 
 #include "Multilevel.h"
 
+#include <algorithm>
+#include <boost/range/iterator_range_core.hpp>
 #include <functional>
+#include <limits>
+#include <numeric>
 #include <queue>
 #include <random>
 #include <thread>
+#include <utility>
+#include <vector>
 
+#include "Coarsener.h"
 #include "Evaluator.h"
+#include "GreedyRefine.h"
 #include "Hypergraph.h"
+#include "ILPRefine.h"
+#include "KWayFMRefine.h"
+#include "KWayPMRefine.h"
 #include "Partitioner.h"
+#include "Utilities.h"
 #include "utl/Logger.h"
 
 namespace par {
diff --git a/src/par/src/Multilevel.h b/src/par/src/Multilevel.h
index c3e165a363f..11016611b80 100644
--- a/src/par/src/Multilevel.h
+++ b/src/par/src/Multilevel.h
@@ -34,6 +34,9 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
+#include <memory>
+#include <vector>
+
 #include "Coarsener.h"
 #include "Evaluator.h"
 #include "GreedyRefine.h"
diff --git a/src/par/src/PartitionMgr.cpp b/src/par/src/PartitionMgr.cpp
index f9a63c7d2b5..f487218c0cc 100644
--- a/src/par/src/PartitionMgr.cpp
+++ b/src/par/src/PartitionMgr.cpp
@@ -36,17 +36,24 @@
 #include "par/PartitionMgr.h"
 
 #include <algorithm>
-#include <chrono>
 #include <cmath>
 #include <ctime>
 #include <fstream>
 #include <iostream>
+#include <map>
+#include <memory>
+#include <set>
+#include <stdexcept>
+#include <string>
+#include <vector>
 
 #include "TritonPart.h"
-#include "Utilities.h"
 #include "db_sta/dbSta.hh"
 #include "odb/db.h"
+#include "sta/ConcreteNetwork.hh"
+#include "sta/Liberty.hh"
 #include "sta/MakeConcreteNetwork.hh"
+#include "sta/NetworkClass.hh"
 #include "sta/ParseBus.hh"
 #include "sta/PortDirection.hh"
 #include "sta/VerilogWriter.hh"
diff --git a/src/par/src/Partitioner.cpp b/src/par/src/Partitioner.cpp
index 9a01437d8c7..3fb6a89f0fb 100644
--- a/src/par/src/Partitioner.cpp
+++ b/src/par/src/Partitioner.cpp
@@ -35,7 +35,13 @@
 
 #include "Partitioner.h"
 
+#include <algorithm>
+#include <map>
+#include <numeric>
 #include <random>
+#include <set>
+#include <utility>
+#include <vector>
 
 #include "Evaluator.h"
 #include "Hypergraph.h"
diff --git a/src/par/src/Partitioner.h b/src/par/src/Partitioner.h
index c72a6d49d84..7d980c1b76d 100644
--- a/src/par/src/Partitioner.h
+++ b/src/par/src/Partitioner.h
@@ -43,6 +43,9 @@
 // then put remaining vertices into the first block 3) ILP-based Partitioning
 // (INIT_DIRECT_ILP)
 
+#include <memory>
+#include <vector>
+
 #include "Evaluator.h"
 #include "Hypergraph.h"
 #include "Utilities.h"
diff --git a/src/par/src/PriorityQueue.cpp b/src/par/src/PriorityQueue.cpp
index 5665b6b3013..2054bd6446c 100644
--- a/src/par/src/PriorityQueue.cpp
+++ b/src/par/src/PriorityQueue.cpp
@@ -35,7 +35,12 @@
 
 #include "PriorityQueue.h"
 
+#include <algorithm>
+#include <memory>
+#include <utility>
+
 #include "Hypergraph.h"
+#include "Utilities.h"
 
 namespace par {
 
diff --git a/src/par/src/PriorityQueue.h b/src/par/src/PriorityQueue.h
index 1a8da15bf26..7d923109069 100644
--- a/src/par/src/PriorityQueue.h
+++ b/src/par/src/PriorityQueue.h
@@ -34,9 +34,14 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
+#include <cmath>
+#include <limits>
+#include <map>
+#include <memory>
+#include <vector>
 
 #include "Hypergraph.h"
+#include "Utilities.h"
 
 namespace par {
 
diff --git a/src/par/src/Refiner.cpp b/src/par/src/Refiner.cpp
index e57d4e443da..e332eeca988 100644
--- a/src/par/src/Refiner.cpp
+++ b/src/par/src/Refiner.cpp
@@ -34,6 +34,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "Refiner.h"
 
+#include <map>
+#include <memory>
+#include <set>
+#include <utility>
+#include <vector>
+
 #include "Evaluator.h"
 #include "Hypergraph.h"
 #include "Utilities.h"
diff --git a/src/par/src/Refiner.h b/src/par/src/Refiner.h
index ebda4926d5c..8125eb07e1b 100644
--- a/src/par/src/Refiner.h
+++ b/src/par/src/Refiner.h
@@ -34,7 +34,10 @@
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
 
-#include <set>
+#include <map>
+#include <memory>
+#include <utility>
+#include <vector>
 
 #include "Evaluator.h"
 #include "Hypergraph.h"
diff --git a/src/par/src/TritonPart.cpp b/src/par/src/TritonPart.cpp
index 0e369c59f9e..b3d47939820 100644
--- a/src/par/src/TritonPart.cpp
+++ b/src/par/src/TritonPart.cpp
@@ -40,39 +40,46 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "TritonPart.h"
 
+#include <algorithm>
+#include <chrono>
+#include <cmath>
+#include <cstdlib>
+#include <fstream>
 #include <iostream>
+#include <iterator>
+#include <memory>
 #include <set>
+#include <sstream>
 #include <string>
+#include <vector>
 
 #include "Coarsener.h"
+#include "Evaluator.h"
+#include "GreedyRefine.h"
 #include "Hypergraph.h"
+#include "ILPRefine.h"
+#include "KWayFMRefine.h"
+#include "KWayPMRefine.h"
 #include "Multilevel.h"
 #include "Partitioner.h"
-#include "Refiner.h"
 #include "Utilities.h"
+#include "db_sta/dbNetwork.hh"
+#include "db_sta/dbSta.hh"
 #include "odb/db.h"
-#include "sta/ArcDelayCalc.hh"
-#include "sta/Bfs.hh"
-#include "sta/Corner.hh"
-#include "sta/DcalcAnalysisPt.hh"
+#include "odb/geom.h"
 #include "sta/ExceptionPath.hh"
-#include "sta/FuncExpr.hh"
 #include "sta/Graph.hh"
-#include "sta/GraphDelayCalc.hh"
 #include "sta/Liberty.hh"
-#include "sta/Network.hh"
+#include "sta/MinMax.hh"
+#include "sta/NetworkClass.hh"
 #include "sta/PathAnalysisPt.hh"
 #include "sta/PathEnd.hh"
 #include "sta/PathExpanded.hh"
 #include "sta/PathRef.hh"
-#include "sta/PatternMatch.hh"
-#include "sta/PortDirection.hh"
 #include "sta/Sdc.hh"
 #include "sta/Search.hh"
-#include "sta/SearchPred.hh"
-#include "sta/Sequential.hh"
+#include "sta/SearchClass.hh"
 #include "sta/Sta.hh"
-#include "sta/Units.hh"
 #include "utl/Logger.h"
 
 using utl::PAR;
@@ -83,7 +90,7 @@ namespace par {
 // Public functions
 // -----------------------------------------------------------------------------------
 
-TritonPart::TritonPart(ord::dbNetwork* network,
+TritonPart::TritonPart(sta::dbNetwork* network,
                        odb::dbDatabase* db,
                        sta::dbSta* sta,
                        utl::Logger* logger)
diff --git a/src/par/src/TritonPart.h b/src/par/src/TritonPart.h
index 297c82844f7..202e0da1460 100644
--- a/src/par/src/TritonPart.h
+++ b/src/par/src/TritonPart.h
@@ -33,22 +33,15 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 #pragma once
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <queue>
 #include <string>
 #include <vector>
 
 #include "Coarsener.h"
 #include "Hypergraph.h"
+#include "Utilities.h"
 #include "db_sta/dbReadVerilog.hh"
 #include "db_sta/dbSta.hh"
 #include "odb/db.h"
-#include "sta/Bfs.hh"
-#include "sta/Graph.hh"
-#include "sta/Liberty.hh"
-#include "sta/Sta.hh"
 #include "utl/Logger.h"
 
 namespace par {
@@ -68,7 +61,7 @@ namespace par {
 class TritonPart
 {
  public:
-  TritonPart(ord::dbNetwork* network,
+  TritonPart(sta::dbNetwork* network,
              odb::dbDatabase* db,
              sta::dbSta* sta,
              utl::Logger* logger);
diff --git a/src/par/src/Utilities.cpp b/src/par/src/Utilities.cpp
index 34c246e210f..5a64bf4d103 100644
--- a/src/par/src/Utilities.cpp
+++ b/src/par/src/Utilities.cpp
@@ -37,29 +37,18 @@
 ///////////////////////////////////////////////////////////////////////////////
 #include "Utilities.h"
 
-#include <ortools/base/commandlineflags.h>
-#include <ortools/base/logging.h>
 #include <ortools/linear_solver/linear_solver.h>
-#include <ortools/linear_solver/linear_solver.pb.h>
 
 #include <algorithm>
 #include <cassert>
-#include <chrono>
 #include <climits>
 #include <cmath>
-#include <fstream>
 #include <functional>
-#include <iomanip>
-#include <iostream>
 #include <iterator>
 #include <map>
-#include <queue>
-#include <random>
-#include <sstream>
-#include <stack>
-#include <stdexcept>
+#include <memory>
+#include <numeric>
 #include <string>
-#include <thread>
 #include <vector>
 
 namespace par {