diff --git a/src/ant/src/AntennaChecker.cc b/src/ant/src/AntennaChecker.cc index eb18b7bf766..0687456462f 100644 --- a/src/ant/src/AntennaChecker.cc +++ b/src/ant/src/AntennaChecker.cc @@ -1212,8 +1212,7 @@ int AntennaChecker::Impl::checkAntennas(odb::dbNet* net, } omp_set_num_threads(num_threads); #pragma omp parallel for schedule(dynamic) - for (int i = 0; i < nets_.size(); i++) { - odb::dbNet* net = nets_[i]; + for (auto net : nets_) { Violations antenna_violations; int pin_viol_count = checkNet(net, verbose, true, nullptr, 0, antenna_violations); diff --git a/src/ant/src/Polygon.cc b/src/ant/src/Polygon.cc index 71d89c21d5d..149ef080844 100644 --- a/src/ant/src/Polygon.cc +++ b/src/ant/src/Polygon.cc @@ -15,10 +15,6 @@ namespace ant { -using gtl::operators::operator+=; -using gtl::operators::operator-=; -using gtl::operators::operator&; - Polygon rectToPolygon(const odb::Rect& rect) { std::vector points{{gtl::construct(rect.xMin(), rect.yMin()), @@ -34,6 +30,9 @@ Polygon rectToPolygon(const odb::Rect& rect) std::vector findNodesWithIntersection(const GraphNodes& graph_nodes, const Polygon& pol) { + using gtl::operators::operator+=; + using gtl::operators::operator&; + // expand object by 1 PolygonSet obj; obj += pol; @@ -53,6 +52,8 @@ std::vector findNodesWithIntersection(const GraphNodes& graph_nodes, void wiresToPolygonSetMap(odb::dbWire* wires, std::map& set_by_layer) { + using gtl::operators::operator+=; + odb::dbShape shape; odb::dbWireShapeItr shapes_it; std::vector via_boxes; @@ -85,6 +86,8 @@ void wiresToPolygonSetMap(odb::dbWire* wires, void avoidPinIntersection(odb::dbNet* db_net, std::map& set_by_layer) { + using gtl::operators::operator-=; + // iterate all instance pin for (odb::dbITerm* iterm : db_net->getITerms()) { odb::dbMTerm* mterm = iterm->getMTerm(); diff --git a/src/cts/src/HTreeBuilder.cpp b/src/cts/src/HTreeBuilder.cpp index 5e0eb02ec2c..98c822059a5 100644 --- a/src/cts/src/HTreeBuilder.cpp +++ b/src/cts/src/HTreeBuilder.cpp @@ -323,7 +323,9 @@ void HTreeBuilder::initSinkRegion() logger_->info(CTS, 26, " Height: {:.4f}.", sinkRegion_.getHeight()); } -void plotBlockage(std::ofstream& file, odb::dbDatabase* db_, int scalingFactor) +static void plotBlockage(std::ofstream& file, + odb::dbDatabase* db_, + int scalingFactor) { unsigned i = 0; for (odb::dbBlockage* blockage : db_->getChip()->getBlock()->getBlockages()) { @@ -351,7 +353,8 @@ double HTreeBuilder::weightedDistance(const Point& newLoc, return dist; } -void plotSinks(std::ofstream& file, const std::vector>& sinks) +static void plotSinks(std::ofstream& file, + const std::vector>& sinks) { unsigned cnt = 0; for (const Point& pt : sinks) { @@ -407,9 +410,9 @@ void HTreeBuilder::scalePosition(Point& loc, loc.setY(y); } -void setSiblingPosition(const Point& a, - Point& b, - const Point& parLoc) +static void setSiblingPosition(const Point& a, + Point& b, + const Point& parLoc) { double px = parLoc.getX(); double py = parLoc.getY(); diff --git a/src/cts/src/TritonCTS.cpp b/src/cts/src/TritonCTS.cpp index 3210e855319..d74536597db 100644 --- a/src/cts/src/TritonCTS.cpp +++ b/src/cts/src/TritonCTS.cpp @@ -685,13 +685,6 @@ void TritonCTS::setBufferList(const char* buffers) options_->setBufferList(bufferList); } -std::string toLowerCase(std::string str) -{ - std::ranges::transform( - str, str.begin(), [](unsigned char c) { return std::tolower(c); }); - return str; -} - std::string TritonCTS::getRootBufferToString() { std::ostringstream buffer_names; @@ -2235,7 +2228,7 @@ double TritonCTS::computeInsertionDelay(const std::string& name, return insDelayPerMicron; } -float getInputCap(const sta::LibertyCell* cell) +static float getInputCap(const sta::LibertyCell* cell) { sta::LibertyPort *in, *out; cell->bufferPorts(in, out); @@ -2245,7 +2238,7 @@ float getInputCap(const sta::LibertyCell* cell) return 0.0; } -sta::LibertyCell* findBestDummyCell( +static sta::LibertyCell* findBestDummyCell( const std::vector& dummyCandidates, float deltaCap) { diff --git a/src/dbSta/src/SpefWriter.cc b/src/dbSta/src/SpefWriter.cc index 21030be5ee9..5577a7925d9 100644 --- a/src/dbSta/src/SpefWriter.cc +++ b/src/dbSta/src/SpefWriter.cc @@ -38,7 +38,7 @@ SpefWriter::SpefWriter(Logger* logger, writePorts(); } -std::string escapeSpecial(const std::string& name) +static std::string escapeSpecial(const std::string& name) { std::string result = name; size_t pos = 0; @@ -49,7 +49,7 @@ std::string escapeSpecial(const std::string& name) return result; } -std::string escapeSpecial(const char* name) +static std::string escapeSpecial(const char* name) { if (!name) { return ""; @@ -60,7 +60,7 @@ std::string escapeSpecial(const char* name) // Quick fix for wrong pin delimiter. // TODO: save the parasitics data to odb and use the existing write_spef // mechanism to produce the spef files from estimate_parasitics. -std::string fixPinDelimiter(const std::string& name) +static std::string fixPinDelimiter(const std::string& name) { const char delimiter = '/'; std::string result = name; @@ -104,7 +104,7 @@ void SpefWriter::writeHeader() } } -char getIoDirectionText(const odb::dbIoType& io_type) +static char getIoDirectionText(const odb::dbIoType& io_type) { if (io_type == odb::dbIoType::INPUT) { return 'I'; diff --git a/src/dbSta/src/dbSta.cc b/src/dbSta/src/dbSta.cc index 0c00843f176..2a389fc14b7 100644 --- a/src/dbSta/src/dbSta.cc +++ b/src/dbSta/src/dbSta.cc @@ -571,7 +571,7 @@ void dbSta::countPhysicalOnlyInstancesByType(InstTypeMap& inst_type_stats, } } -std::string toLowerCase(std::string str) +static std::string toLowerCase(std::string str) { std::ranges::transform( str, str.begin(), [](unsigned char c) { return std::tolower(c); }); diff --git a/src/dbSta/test/cpp/TestHconn.cpp b/src/dbSta/test/cpp/TestHconn.cpp index bf32a307a90..074af0764a8 100644 --- a/src/dbSta/test/cpp/TestHconn.cpp +++ b/src/dbSta/test/cpp/TestHconn.cpp @@ -34,13 +34,14 @@ namespace odb { static const std::string prefix("_main/src/dbSta/test/"); +static constexpr bool kDebugMsgs = false; /* Extract the hierarchical information in human readable format. Shows the dbNet and dbModNet view of the database. */ -void DbStrDebugHierarchy(dbBlock* block, std::stringstream& str_db) +static void DbStrDebugHierarchy(dbBlock* block, std::stringstream& str_db) { str_db << fmt::format("Debug: Data base tables for block at {}:\n", block->getName()); @@ -527,9 +528,11 @@ class TestHconn : public ::tst::Fixture inv4_3_op_->connect(op2_net_); inv4_4_op_->connect(op3_net_); - // std::stringstream str_str; - // DbStrDebugHierarchy(block_, str_str); - // printf("The Flat design created %s\n", str_str.str().c_str()); + if (kDebugMsgs) { + std::stringstream str_str; + DbStrDebugHierarchy(block_, str_str); + printf("The Flat design created %s\n", str_str.str().c_str()); + } // Now build the hierarchical "overlay" // What we are doing here is adding the modnets which hook up @@ -645,11 +648,12 @@ class TestHconn : public ::tst::Fixture inv4_mod_level2_inst_o3_miterm_->connect(inv4_mod_level2_inst_o3_mnet_); inv4_mod_level1_master_o3_port_->connect(inv4_mod_level2_inst_o3_mnet_); - // Uncomment this to see the full design - // std::stringstream full_design; - // DbStrDebugHierarchy(block_, full_design); - // printf("The design created (flat and hierarchical) %s\n", - // full_design.str().c_str()); + if (kDebugMsgs) { + std::stringstream full_design; + DbStrDebugHierarchy(block_, full_design); + printf("The design created (flat and hierarchical) %s\n", + full_design.str().c_str()); + } } sta::LibertyLibrary* library_; @@ -788,9 +792,11 @@ class TestHconn : public ::tst::Fixture TEST_F(TestHconn, ConnectionMade) { - // std::stringstream str_str_initial; - // DbStrDebugHierarchy(block_, str_str_initial); - // printf("The initial design: %s\n", str_str_initial.str().c_str()); + if (kDebugMsgs) { + std::stringstream str_str_initial; + DbStrDebugHierarchy(block_, str_str_initial); + printf("The initial design: %s\n", str_str_initial.str().c_str()); + } // ECO test: get initial state before we start modifying // the design. Then at end we undo everything and @@ -896,10 +902,11 @@ TEST_F(TestHconn, ConnectionMade) db_network_->hierarchicalConnect( inv1_2_inst_op0, inv4_4_ip_, hier_net_name.c_str()); - // Uncomment this to see the final design - // std::stringstream str_str_final; - // DbStrDebugHierarchy(block_, str_str_final); - // printf("The final design: %s\n", str_str_final.str().c_str()); + if (kDebugMsgs) { + std::stringstream str_str_final; + DbStrDebugHierarchy(block_, str_str_final); + printf("The final design: %s\n", str_str_final.str().c_str()); + } // Example of how to turn on the call backs for all the bterms/iterms // used by the sta diff --git a/src/dpl/src/CheckPlacement.cpp b/src/dpl/src/CheckPlacement.cpp index ed2cbd7a89d..5ba8f5d7429 100644 --- a/src/dpl/src/CheckPlacement.cpp +++ b/src/dpl/src/CheckPlacement.cpp @@ -22,7 +22,7 @@ using std::vector; using utl::DPL; -using utl::format_as; +using utl::format_as; // NOLINT(misc-unused-using-decls) void Opendp::checkPlacement(const bool verbose, const std::string& report_file_name) diff --git a/src/dpl/src/FillerPlacement.cpp b/src/dpl/src/FillerPlacement.cpp index 7e5bad2f561..775935e4e7b 100644 --- a/src/dpl/src/FillerPlacement.cpp +++ b/src/dpl/src/FillerPlacement.cpp @@ -22,7 +22,7 @@ using utl::DPL; using odb::dbMaster; using odb::dbPlacementStatus; -using utl::format_as; +using utl::format_as; // NOLINT(misc-unused-using-decls) static odb::dbTechLayer* getImplant(dbMaster* master) { diff --git a/src/dpl/src/OptMirror.cpp b/src/dpl/src/OptMirror.cpp index f4c3cecf2f7..49d3d827654 100644 --- a/src/dpl/src/OptMirror.cpp +++ b/src/dpl/src/OptMirror.cpp @@ -19,7 +19,6 @@ namespace dpl { using utl::DPL; -using std::sort; using std::unordered_set; using odb::dbITerm; diff --git a/src/dpl/src/Place.cpp b/src/dpl/src/Place.cpp index 33f1e7ed86f..384b66dc3eb 100644 --- a/src/dpl/src/Place.cpp +++ b/src/dpl/src/Place.cpp @@ -39,13 +39,12 @@ namespace dpl { using std::max; using std::min; using std::numeric_limits; -using std::sort; using std::string; using std::vector; using utl::DPL; -using utl::format_as; +using utl::format_as; // NOLINT(misc-unused-using-decls) std::string Opendp::printBgBox( const boost::geometry::model::box& queryBox) diff --git a/src/dpl/src/infrastructure/Grid.cpp b/src/dpl/src/infrastructure/Grid.cpp index b663ec0f6cf..c973625f41f 100644 --- a/src/dpl/src/infrastructure/Grid.cpp +++ b/src/dpl/src/infrastructure/Grid.cpp @@ -35,7 +35,7 @@ using utl::DPL; using odb::dbBox; using odb::dbRow; -using utl::format_as; +using utl::format_as; // NOLINT(misc-unused-using-decls) PixelPt::PixelPt(Pixel* pixel1, GridX grid_x, GridY grid_y) : pixel(pixel1), x(grid_x), y(grid_y) diff --git a/src/dpl/src/optimization/detailed_mis.cxx b/src/dpl/src/optimization/detailed_mis.cxx index dd9a6869945..0180fc7341b 100644 --- a/src/dpl/src/optimization/detailed_mis.cxx +++ b/src/dpl/src/optimization/detailed_mis.cxx @@ -373,8 +373,8 @@ void DetailedMis::populateGrid() // Inserts movable cells into the grid. for (auto& row : grid_) { - for (size_t j = 0; j < row.size(); j++) { - row[j]->clear(); + for (auto& bucket : row) { + bucket->clear(); } } diff --git a/src/drt/src/gc/FlexGC_main.cpp b/src/drt/src/gc/FlexGC_main.cpp index 534652fec6d..db3084e6991 100644 --- a/src/drt/src/gc/FlexGC_main.cpp +++ b/src/drt/src/gc/FlexGC_main.cpp @@ -2227,7 +2227,7 @@ bool FlexGCWorker::Impl::checkMetalShape_lef58Area_rectWidth( gtl::get_max_rectangles(rects, polySet); if (rects.size() == 1) { int min_width = db_rule->getRectWidth(); - auto rect = rects.back(); + const auto& rect = rects.back(); auto xLen = gtl::delta(rect, gtl::HORIZONTAL); auto yLen = gtl::delta(rect, gtl::VERTICAL); bool apply_rect_width_area = false; diff --git a/src/dst/include/dst/BalancerJobDescription.h b/src/dst/include/dst/BalancerJobDescription.h index 37a84bdd781..a31f80eaf8a 100644 --- a/src/dst/include/dst/BalancerJobDescription.h +++ b/src/dst/include/dst/BalancerJobDescription.h @@ -2,26 +2,30 @@ // Copyright (c) 2021-2025, The OpenROAD Authors #pragma once + +#include #include #include "boost/serialization/base_object.hpp" #include "dst/JobMessage.h" + namespace boost::serialization { class access; } + namespace dst { class BalancerJobDescription : public JobDescription { public: void setWorkerIP(const std::string& ip) { worker_ip_ = ip; } - void setWorkerPort(unsigned short port) { worker_port_ = port; } + void setWorkerPort(uint16_t port) { worker_port_ = port; } std::string getWorkerIP() const { return worker_ip_; } - unsigned short getWorkerPort() const { return worker_port_; } + uint16_t getWorkerPort() const { return worker_port_; } private: std::string worker_ip_; - unsigned short worker_port_{0}; + uint16_t worker_port_{0}; template void serialize(Archive& ar, const unsigned int version) @@ -32,4 +36,5 @@ class BalancerJobDescription : public JobDescription } friend class boost::serialization::access; }; + } // namespace dst diff --git a/src/dst/include/dst/BroadcastJobDescription.h b/src/dst/include/dst/BroadcastJobDescription.h index df8bf166486..9a49f9d68cb 100644 --- a/src/dst/include/dst/BroadcastJobDescription.h +++ b/src/dst/include/dst/BroadcastJobDescription.h @@ -2,21 +2,26 @@ // Copyright (c) 2022-2025, The OpenROAD Authors #pragma once + +#include + #include "boost/serialization/base_object.hpp" #include "dst/JobMessage.h" + namespace boost::serialization { class access; } + namespace dst { class BroadcastJobDescription : public JobDescription { public: - void setWorkersCount(unsigned short count) { workers_count_ = count; } - unsigned short getWorkersCount() const { return workers_count_; } + void setWorkersCount(uint16_t count) { workers_count_ = count; } + uint16_t getWorkersCount() const { return workers_count_; } private: - unsigned short workers_count_{0}; + uint16_t workers_count_{0}; template void serialize(Archive& ar, const unsigned int version) @@ -26,4 +31,5 @@ class BroadcastJobDescription : public JobDescription } friend class boost::serialization::access; }; + } // namespace dst diff --git a/src/dst/include/dst/Distributed.h b/src/dst/include/dst/Distributed.h index cade2574237..082425d6c96 100644 --- a/src/dst/include/dst/Distributed.h +++ b/src/dst/include/dst/Distributed.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -49,8 +50,8 @@ class Distributed struct EndPoint { std::string ip; - unsigned short port; - EndPoint(const std::string& ip_in, unsigned short port_in) + uint16_t port; + EndPoint(const std::string& ip_in, uint16_t port_in) : ip(ip_in), port(port_in) { } diff --git a/src/dst/src/BalancerConnection.cc b/src/dst/src/BalancerConnection.cc index fc361f15cb5..bbddac259af 100644 --- a/src/dst/src/BalancerConnection.cc +++ b/src/dst/src/BalancerConnection.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -154,7 +155,7 @@ void BalancerConnection::handle_read(boost::system::error_code const& err, asio::thread_pool pool(owner_->workers_.size()); auto workers_copy = owner_->workers_; std::mutex broadcast_failure_mutex; - std::vector> failed_workers; + std::vector> failed_workers; while (!workers_copy.empty()) { auto worker = workers_copy.top(); workers_copy.pop(); @@ -182,7 +183,7 @@ void BalancerConnection::handle_read(boost::system::error_code const& err, pool.join(); JobMessage result(JobMessage::kSuccess); std::string msg_str; - unsigned short success_broadcast + uint16_t success_broadcast = owner_->workers_.size() - failed_workers.size(); if (!failed_workers.empty()) { for (const auto& worker : failed_workers) { diff --git a/src/dst/src/LoadBalancer.cc b/src/dst/src/LoadBalancer.cc index 8592a2d9d0a..b614b9c7c6b 100644 --- a/src/dst/src/LoadBalancer.cc +++ b/src/dst/src/LoadBalancer.cc @@ -4,6 +4,7 @@ #include "LoadBalancer.h" #include +#include #include #include #include @@ -116,7 +117,7 @@ void LoadBalancer::updateWorker(const ip::address& ip, unsigned short port) } workers_.swap(new_queue); } -void LoadBalancer::getNextWorker(ip::address& ip, unsigned short& port) +void LoadBalancer::getNextWorker(ip::address& ip, uint16_t& port) { std::lock_guard lock(workers_mutex_); if (!workers_.empty()) { @@ -124,14 +125,14 @@ void LoadBalancer::getNextWorker(ip::address& ip, unsigned short& port) workers_.pop(); ip = w.ip; port = w.port; - if (w.priority != std::numeric_limits::max()) { + if (w.priority != std::numeric_limits::max()) { w.priority++; } workers_.push(w); } } -void LoadBalancer::punishWorker(const ip::address& ip, unsigned short port) +void LoadBalancer::punishWorker(const ip::address& ip, uint16_t port) { std::lock_guard lock(workers_mutex_); std::priority_queue, CompareWorker> new_queue; @@ -146,9 +147,7 @@ void LoadBalancer::punishWorker(const ip::address& ip, unsigned short port) workers_.swap(new_queue); } -void LoadBalancer::removeWorker(const ip::address& ip, - unsigned short port, - bool lock) +void LoadBalancer::removeWorker(const ip::address& ip, uint16_t port, bool lock) { if (lock) { workers_mutex_.lock(); @@ -168,7 +167,7 @@ void LoadBalancer::removeWorker(const ip::address& ip, } } -void LoadBalancer::lookUpWorkers(const char* domain, unsigned short port) +void LoadBalancer::lookUpWorkers(const char* domain, uint16_t port) { asio::io_context ios; std::vector workers_set; diff --git a/src/dst/src/LoadBalancer.h b/src/dst/src/LoadBalancer.h index e02396f89b1..0fb77d2735b 100644 --- a/src/dst/src/LoadBalancer.h +++ b/src/dst/src/LoadBalancer.h @@ -13,6 +13,7 @@ #include "BalancerConnection.h" #include "boost/asio.hpp" +#include "boost/asio/ip/address.hpp" #include "boost/asio/thread_pool.hpp" #include "boost/thread/thread.hpp" @@ -37,23 +38,21 @@ class LoadBalancer utl::Logger* logger, const char* ip, const char* workers_domain, - unsigned short port = 1234); + uint16_t port = 1234); ~LoadBalancer(); - bool addWorker(const std::string& ip, unsigned short port); - void updateWorker(const ip::address& ip, unsigned short port); - void getNextWorker(ip::address& ip, unsigned short& port); - void removeWorker(const ip::address& ip, - unsigned short port, - bool lock = true); - void punishWorker(const ip::address& ip, unsigned short port); + bool addWorker(const std::string& ip, uint16_t port); + void updateWorker(const ip::address& ip, uint16_t port); + void getNextWorker(ip::address& ip, uint16_t& port); + void removeWorker(const ip::address& ip, uint16_t port, bool lock = true); + void punishWorker(const ip::address& ip, uint16_t port); private: struct Worker { ip::address ip; - unsigned short port; - unsigned short priority; - Worker(const ip::address& ip, unsigned short port, unsigned short priority) + uint16_t port; + uint16_t priority; + Worker(const ip::address& ip, uint16_t port, uint16_t priority) : ip(ip), port(port), priority(priority) { } @@ -86,7 +85,7 @@ class LoadBalancer void start_accept(); void handle_accept(const BalancerConnection::Pointer& connection, const boost::system::error_code& err); - void lookUpWorkers(const char* domain, unsigned short port); + void lookUpWorkers(const char* domain, uint16_t port); friend class dst::BalancerConnection; }; } // namespace dst diff --git a/src/dst/test/cpp/TestBalancer.cc b/src/dst/test/cpp/TestBalancer.cc index 3d82ec0da55..957634d3818 100644 --- a/src/dst/test/cpp/TestBalancer.cc +++ b/src/dst/test/cpp/TestBalancer.cc @@ -1,3 +1,4 @@ +#include #include #include "HelperCallBack.h" @@ -18,11 +19,11 @@ TEST(test_suite, test_balancer) utl::Logger* logger = new utl::Logger(); Distributed* dist = new Distributed(logger); std::string local_ip = "127.0.0.1"; - unsigned short balancer_port = 5555; - unsigned short worker_port_1 = 5556; - unsigned short worker_port_2 = 5557; - unsigned short worker_port_3 = 5558; - unsigned short worker_port_4 = 5559; + uint16_t balancer_port = 5555; + uint16_t worker_port_1 = 5556; + uint16_t worker_port_2 = 5557; + uint16_t worker_port_3 = 5558; + uint16_t worker_port_4 = 5559; asio::io_context service; LoadBalancer* balancer = new LoadBalancer( dist, service, logger, local_ip.c_str(), "", balancer_port); @@ -31,7 +32,7 @@ TEST(test_suite, test_balancer) balancer->addWorker(local_ip, worker_port_1); balancer->addWorker(local_ip, worker_port_2); asio::ip::address address; - unsigned short port; + uint16_t port; balancer->getNextWorker(address, port); EXPECT_EQ(address.to_string(), local_ip); diff --git a/src/dst/test/cpp/TestDistributed.cc b/src/dst/test/cpp/TestDistributed.cc index a848859ea78..753ed7562c9 100644 --- a/src/dst/test/cpp/TestDistributed.cc +++ b/src/dst/test/cpp/TestDistributed.cc @@ -1,3 +1,4 @@ +#include #include #include @@ -17,8 +18,8 @@ TEST(test_suite, test_distributed) utl::Logger* logger = new utl::Logger(); Distributed* dist = new Distributed(logger); std::string local_ip = "127.0.0.1"; - unsigned short worker_port = 1235; - unsigned short balancer_port = 1236; + uint16_t worker_port = 1235; + uint16_t balancer_port = 1236; // Test callbacks interface dist->addCallBack(new HelperCallBack(dist)); diff --git a/src/gpl/src/fft.cpp b/src/gpl/src/fft.cpp index 5e4b545b236..6f0ff544631 100644 --- a/src/gpl/src/fft.cpp +++ b/src/gpl/src/fft.cpp @@ -7,10 +7,9 @@ #include #include #include +#include #include -#define REPLACE_FFT_PI 3.141592653589793238462L - namespace gpl { FFT::FFT(int binCntX, int binCntY, float binSizeX, float binSizeY) @@ -45,15 +44,16 @@ FFT::FFT(int binCntX, int binCntY, float binSizeX, float binSizeY) workArea_.resize(round(sqrt(std::max(binCntX_, binCntY_))) + 2, 0); + constexpr auto kPi = std::numbers::pi_v; + for (int i = 0; i < binCntX_; i++) { - wx_[i] - = REPLACE_FFT_PI * static_cast(i) / static_cast(binCntX_); + wx_[i] = kPi * static_cast(i) / static_cast(binCntX_); wxSquare_[i] = wx_[i] * wx_[i]; } for (int i = 0; i < binCntY_; i++) { - wy_[i] = REPLACE_FFT_PI * static_cast(i) - / static_cast(binCntY_) * binSizeY_ / binSizeX_; + wy_[i] = kPi * static_cast(i) / static_cast(binCntY_) + * binSizeY_ / binSizeX_; wySquare_[i] = wy_[i] * wy_[i]; } } diff --git a/src/gpl/src/fft.h b/src/gpl/src/fft.h index c965bdefc44..0466172eaa8 100644 --- a/src/gpl/src/fft.h +++ b/src/gpl/src/fft.h @@ -61,24 +61,23 @@ class FFT // /// 1D FFT //////////////////////////////////////////////////////////////// void cdft(int n, int isgn, float* a, int* ip, float* w); +void rdft(int n, int isgn, float* a, int* ip, float* w); void ddct(int n, int isgn, float* a, int* ip, float* w); void ddst(int n, int isgn, float* a, int* ip, float* w); +void dfct(int n, float* a, float* t, int* ip, float* w); +void dfst(int n, float* a, float* t, int* ip, float* w); /// 2D FFT //////////////////////////////////////////////////////////////// void cdft2d(int, int, int, float**, float*, int*, float*); void rdft2d(int, int, int, float**, float*, int*, float*); +void rdft2dsort(int n1, int n2, int isgn, float** a); void ddct2d(int, int, int, float**, float*, int*, float*); void ddst2d(int, int, int, float**, float*, int*, float*); void ddsct2d(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w); void ddcst2d(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w); -/// 3D FFT //////////////////////////////////////////////////////////////// -void cdft3d(int, int, int, int, float***, float*, int*, float*); -void rdft3d(int, int, int, int, float***, float*, int*, float*); -void ddct3d(int, int, int, int, float***, float*, int*, float*); -void ddst3d(int, int, int, int, float***, float*, int*, float*); -void ddscct3d(int, int, int, int isgn, float***, float*, int*, float*); -void ddcsct3d(int, int, int, int isgn, float***, float*, int*, float*); -void ddccst3d(int, int, int, int isgn, float***, float*, int*, float*); +/// Utils ///////////////////////////////////////////////////////////////// +void makect(int nc, int* ip, float* c); +void makewt(int nw, int* ip, float* w); } // namespace gpl diff --git a/src/gpl/src/fftsg.cpp b/src/gpl/src/fftsg.cpp index 01ebe956ce4..812a37dfbd7 100644 --- a/src/gpl/src/fftsg.cpp +++ b/src/gpl/src/fftsg.cpp @@ -286,42 +286,42 @@ Appendix : #include +#include "fft.h" + namespace gpl { -int cfttree(int n, int j, int k, float* a, int nw, float* w); -void bitrv2(int n, const int* ip, float* a); -void bitrv208(float* a); -void bitrv208neg(float* a); -void bitrv216(float* a); -void bitrv216neg(float* a); -void bitrv2conj(int n, const int* ip, float* a); -void cftb040(float* a); -void cftb1st(int n, float* a, const float* w); -void cftbsub(int n, float* a, int* ip, int nw, float* w); -void cftf040(float* a); -void cftf081(float* a, const float* w); -void cftf082(float* a, const float* w); -void cftf161(float* a, const float* w); -void cftf162(float* a, const float* w); -void cftf1st(int n, float* a, const float* w); -void cftfsub(int n, float* a, int* ip, int nw, float* w); -void cftfx41(int n, float* a, int nw, float* w); -void cftleaf(int n, int isplt, float* a, int nw, float* w); -void cftmdl1(int n, float* a, const float* w); -void cftmdl2(int n, float* a, const float* w); -void cftrec4(int n, float* a, int nw, float* w); -void cftx020(float* a); -void dctsub(int n, float* a, int nc, const float* c); -void dstsub(int n, float* a, int nc, const float* c); -void makect(int nc, int* ip, float* c); -void makeipt(int nw, int* ip); -void makewt(int nw, int* ip, float* w); -void rftbsub(int n, float* a, int nc, const float* c); -void rftfsub(int n, float* a, int nc, const float* c); -void* cftrec1_th(void* p); -void* cftrec2_th(void* p); +static int cfttree(int n, int j, int k, float* a, int nw, float* w); +static void bitrv2(int n, const int* ip, float* a); +static void bitrv208(float* a); +static void bitrv208neg(float* a); +static void bitrv216(float* a); +static void bitrv216neg(float* a); +static void bitrv2conj(int n, const int* ip, float* a); +static void cftb040(float* a); +static void cftb1st(int n, float* a, const float* w); +static void cftbsub(int n, float* a, int* ip, int nw, float* w); +static void cftf040(float* a); +static void cftf081(float* a, const float* w); +static void cftf082(float* a, const float* w); +static void cftf161(float* a, const float* w); +static void cftf162(float* a, const float* w); +static void cftf1st(int n, float* a, const float* w); +static void cftfsub(int n, float* a, int* ip, int nw, float* w); +static void cftfx41(int n, float* a, int nw, float* w); +static void cftleaf(int n, int isplt, float* a, int nw, float* w); +static void cftmdl1(int n, float* a, const float* w); +static void cftmdl2(int n, float* a, const float* w); +static void cftrec4(int n, float* a, int nw, float* w); +static void cftx020(float* a); +static void dctsub(int n, float* a, int nc, const float* c); +static void dstsub(int n, float* a, int nc, const float* c); +static void makeipt(int nw, int* ip); +static void rftbsub(int n, float* a, int nc, const float* c); +static void rftfsub(int n, float* a, int nc, const float* c); #ifdef USE_CDFT_THREADS -void cftrec4_th(int n, float* a, int nw, float* w); +static void* cftrec1_th(void* p); +static void* cftrec2_th(void* p); +static void cftrec4_th(int n, float* a, int nw, float* w); #endif /* USE_CDFT_THREADS */ void cdft(int n, int isgn, float* a, int* ip, float* w) @@ -474,6 +474,7 @@ void ddst(int n, int isgn, float* a, int* ip, float* w) } } +// NOLINTNEXTLINE(misc-use-internal-linkage) void dfct(int n, float* a, float* t, int* ip, float* w) { int j, k, l, m, mh, nw, nc; @@ -561,6 +562,7 @@ void dfct(int n, float* a, float* t, int* ip, float* w) } } +// NOLINTNEXTLINE(misc-use-internal-linkage) void dfst(int n, float* a, float* t, int* ip, float* w) { int j, k, l, m, mh, nw, nc; @@ -700,7 +702,7 @@ void makewt(int nw, int* ip, float* w) } } -void makeipt(int nw, int* ip) +static void makeipt(int nw, int* ip) { int j, l, m, m2, p, q; @@ -798,7 +800,9 @@ void makect(int nc, int* ip, float* c) } #endif /* USE_CDFT_WINTHREADS */ -void cftfsub(int n, float* a, int* ip, int nw, float* w) +// #include "fft.h" + +static void cftfsub(int n, float* a, int* ip, int nw, float* w) { if (n > 8) { if (n > 32) { @@ -830,7 +834,7 @@ void cftfsub(int n, float* a, int* ip, int nw, float* w) } } -void cftbsub(int n, float* a, int* ip, int nw, float* w) +static void cftbsub(int n, float* a, int* ip, int nw, float* w) { if (n > 8) { if (n > 32) { @@ -862,7 +866,7 @@ void cftbsub(int n, float* a, int* ip, int nw, float* w) } } -void bitrv2(int n, const int* ip, float* a) +static void bitrv2(int n, const int* ip, float* a) { int j, j1, k, k1, l, m, nh, nm; float xr, xi, yr, yi; @@ -1208,7 +1212,7 @@ void bitrv2(int n, const int* ip, float* a) } } -void bitrv2conj(int n, const int* ip, float* a) +static void bitrv2conj(int n, const int* ip, float* a) { int j, j1, k, k1, l, m, nh, nm; float xr, xi, yr, yi; @@ -1562,7 +1566,7 @@ void bitrv2conj(int n, const int* ip, float* a) } } -void bitrv216(float* a) +static void bitrv216(float* a) { float x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x7r, x7i, x8r, x8i, x10r, x10i, x11r, x11i, x12r, x12i, x13r, x13i, x14r, x14i; @@ -1617,7 +1621,7 @@ void bitrv216(float* a) a[29] = x7i; } -void bitrv216neg(float* a) +static void bitrv216neg(float* a) { float x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x6r, x6i, x7r, x7i, x8r, x8i, x9r, x9i, x10r, x10i, x11r, x11i, x12r, x12i, x13r, x13i, x14r, @@ -1685,7 +1689,7 @@ void bitrv216neg(float* a) a[31] = x8i; } -void bitrv208(float* a) +static void bitrv208(float* a) { float x1r, x1i, x3r, x3i, x4r, x4i, x6r, x6i; @@ -1707,7 +1711,7 @@ void bitrv208(float* a) a[13] = x3i; } -void bitrv208neg(float* a) +static void bitrv208neg(float* a) { float x1r, x1i, x2r, x2i, x3r, x3i, x4r, x4i, x5r, x5i, x6r, x6i, x7r, x7i; @@ -1741,7 +1745,7 @@ void bitrv208neg(float* a) a[15] = x4i; } -void cftf1st(int n, float* a, const float* w) +static void cftf1st(int n, float* a, const float* w) { int j, j0, j1, j2, j3, k, m, mh; float wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i; @@ -1945,7 +1949,7 @@ void cftf1st(int n, float* a, const float* w) a[j3 + 3] = wk3i * x0i - wk3r * x0r; } -void cftb1st(int n, float* a, const float* w) +static void cftb1st(int n, float* a, const float* w) { int j, j0, j1, j2, j3, k, m, mh; float wn4r, csc1, csc3, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i; @@ -2160,7 +2164,7 @@ struct cdft_arg_st }; using cdft_arg_t = cdft_arg_st; -void cftrec4_th(int n, float* a, int nw, float* w) +static void cftrec4_th(int n, float* a, int nw, float* w) { int i, idiv4, m, nthread; cdft_thread_t th[4]; @@ -2191,7 +2195,7 @@ void cftrec4_th(int n, float* a, int nw, float* w) } } -void* cftrec1_th(void* p) +static void* cftrec1_th(void* p) { int isplt, j, k, m, n, n0, nw; float *a, *w; @@ -2216,7 +2220,7 @@ void* cftrec1_th(void* p) return (void*) 0; } -void* cftrec2_th(void* p) +static void* cftrec2_th(void* p) { int isplt, j, k, m, n, n0, nw; float *a, *w; @@ -2244,7 +2248,7 @@ void* cftrec2_th(void* p) } #endif /* USE_CDFT_THREADS */ -void cftrec4(int n, float* a, int nw, float* w) +static void cftrec4(int n, float* a, int nw, float* w) { int isplt, j, k, m; @@ -2294,7 +2298,7 @@ int cfttree(int n, int j, int k, float* a, int nw, float* w) return isplt; } -void cftleaf(int n, int isplt, float* a, int nw, float* w) +static void cftleaf(int n, int isplt, float* a, int nw, float* w) { if (n == 512) { cftmdl1(128, a, &w[nw - 64]); @@ -2351,7 +2355,7 @@ void cftleaf(int n, int isplt, float* a, int nw, float* w) } } -void cftmdl1(int n, float* a, const float* w) +static void cftmdl1(int n, float* a, const float* w) { int j, j0, j1, j2, j3, k, m, mh; float wn4r, wk1r, wk1i, wk3r, wk3i; @@ -2460,7 +2464,7 @@ void cftmdl1(int n, float* a, const float* w) a[j3 + 1] = -wn4r * (x0i - x0r); } -void cftmdl2(int n, float* a, const float* w) +static void cftmdl2(int n, float* a, const float* w) { int j, j0, j1, j2, j3, k, kr, m, mh; float wn4r, wk1r, wk1i, wk3r, wk3i, wd1r, wd1i, wd3r, wd3i; @@ -2593,7 +2597,7 @@ void cftmdl2(int n, float* a, const float* w) a[j3 + 1] = y0i + y2i; } -void cftfx41(int n, float* a, int nw, float* w) +static void cftfx41(int n, float* a, int nw, float* w) { if (n == 128) { cftf161(a, &w[nw - 8]); @@ -2608,7 +2612,7 @@ void cftfx41(int n, float* a, int nw, float* w) } } -void cftf161(float* a, const float* w) +static void cftf161(float* a, const float* w) { float wn4r, wk1r, wk1i, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i, y8r, y8i, @@ -2764,7 +2768,7 @@ void cftf161(float* a, const float* w) a[7] = x1i - x3r; } -void cftf162(float* a, const float* w) +static void cftf162(float* a, const float* w) { float wn4r, wk1r, wk1i, wk2r, wk2i, wk3r, wk3i, x0r, x0i, x1r, x1i, x2r, x2i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, @@ -2944,7 +2948,7 @@ void cftf162(float* a, const float* w) a[31] = x1i - x2r; } -void cftf081(float* a, const float* w) +static void cftf081(float* a, const float* w) { float wn4r, x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i; @@ -3004,7 +3008,7 @@ void cftf081(float* a, const float* w) a[7] = y2i - y6r; } -void cftf082(float* a, const float* w) +static void cftf082(float* a, const float* w) { float wn4r, wk1r, wk1i, x0r, x0i, x1r, x1i, y0r, y0i, y1r, y1i, y2r, y2i, y3r, y3i, y4r, y4i, y5r, y5i, y6r, y6i, y7r, y7i; @@ -3074,7 +3078,7 @@ void cftf082(float* a, const float* w) a[15] = x0i - x1r; } -void cftf040(float* a) +static void cftf040(float* a) { float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; @@ -3096,7 +3100,7 @@ void cftf040(float* a) a[7] = x1i - x3r; } -void cftb040(float* a) +static void cftb040(float* a) { float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; @@ -3118,7 +3122,7 @@ void cftb040(float* a) a[7] = x1i + x3r; } -void cftx020(float* a) +static void cftx020(float* a) { float x0r, x0i; @@ -3130,7 +3134,7 @@ void cftx020(float* a) a[3] = x0i; } -void rftfsub(int n, float* a, int nc, const float* c) +static void rftfsub(int n, float* a, int nc, const float* c) { int j, k, kk, ks, m; float wkr, wki, xr, xi, yr, yi; @@ -3154,7 +3158,7 @@ void rftfsub(int n, float* a, int nc, const float* c) } } -void rftbsub(int n, float* a, int nc, const float* c) +static void rftbsub(int n, float* a, int nc, const float* c) { int j, k, kk, ks, m; float wkr, wki, xr, xi, yr, yi; @@ -3178,7 +3182,7 @@ void rftbsub(int n, float* a, int nc, const float* c) } } -void dctsub(int n, float* a, int nc, const float* c) +static void dctsub(int n, float* a, int nc, const float* c) { int j, k, kk, ks, m; float wkr, wki, xr; @@ -3198,7 +3202,7 @@ void dctsub(int n, float* a, int nc, const float* c) a[m] *= c[0]; } -void dstsub(int n, float* a, int nc, const float* c) +static void dstsub(int n, float* a, int nc, const float* c) { int j, k, kk, ks, m; float wkr, wki, xr; diff --git a/src/gpl/src/fftsg2d.cpp b/src/gpl/src/fftsg2d.cpp index 6f62ff960a9..0ec2d6899b4 100644 --- a/src/gpl/src/fftsg2d.cpp +++ b/src/gpl/src/fftsg2d.cpp @@ -339,6 +339,7 @@ macro definitions #include #include #include + #define fft2d_alloc_error_check(p) \ { \ if ((p) == NULL) { \ @@ -400,65 +401,39 @@ macro definitions } #endif /* USE_FFT2D_WINTHREADS */ +#include "fft.h" + namespace gpl { -void cdft(int n, int isgn, float* a, int* ip, float* w); -void cdft2d_sub(int n1, - int n2, - int isgn, - float** a, - float* t, - int* ip, - float* w); -void ddct(int n, int isgn, float* a, int* ip, float* w); -void ddst(int n, int isgn, float* a, int* ip, float* w); -void ddxt2d_sub(int n1, - int n2, - int ics, - int isgn, - float** a, - float* t, - int* ip, - float* w); -void makect(int nc, int* ip, float* c); -void makewt(int nw, int* ip, float* w); -void rdft(int n, int isgn, float* a, int* ip, float* w); -void rdft2d_sub(int n1, int isgn, float** a); -void* cdft2d_th(void* p); -void* ddxt2d0_th(void* p); -void* ddxt2d_th(void* p); -#ifdef USE_FFT2D_THREADS -void xdft2d0_subth(int n1, - int n2, - int icr, - int isgn, - float** a, - int* ip, - float* w); -void cdft2d_subth(int n1, - int n2, - int isgn, - float** a, - float* t, - int* ip, - float* w); -#endif /* USE_FFT2D_THREADS */ +static void +cdft2d_sub(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w); +static void ddxt2d_sub(int n1, + int n2, + int ics, + int isgn, + float** a, + float* t, + int* ip, + float* w); +static void rdft2d_sub(int n1, int isgn, float** a); #ifdef USE_FFT2D_THREADS -void ddxt2d0_subth(int n1, - int n2, - int ics, - int isgn, - float** a, - int* ip, - float* w); -void ddxt2d_subth(int n1, - int n2, - int ics, - int isgn, - float** a, - float* t, - int* ip, - float* w); +static void* cdft2d_th(void* p); +static void* ddxt2d0_th(void* p); +static void* ddxt2d_th(void* p); +static void +xdft2d0_subth(int n1, int n2, int icr, int isgn, float** a, int* ip, float* w); +static void +cdft2d_subth(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w); +static void +ddxt2d0_subth(int n1, int n2, int ics, int isgn, float** a, int* ip, float* w); +static void ddxt2d_subth(int n1, + int n2, + int ics, + int isgn, + float** a, + float* t, + int* ip, + float* w); #endif /* USE_FFT2D_THREADS */ void cdft2d(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w) @@ -797,13 +772,8 @@ void ddst2d(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w) /* -------- child routines -------- */ -void cdft2d_sub(int n1, - int n2, - int isgn, - float** a, - float* t, - int* ip, - float* w) +static void +cdft2d_sub(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w) { int i, j; @@ -862,7 +832,7 @@ void cdft2d_sub(int n1, } } -void rdft2d_sub(int n1, int isgn, float** a) +static void rdft2d_sub(int n1, int isgn, float** a) { int n1h, i, j; float xi; @@ -889,14 +859,14 @@ void rdft2d_sub(int n1, int isgn, float** a) } } -void ddxt2d_sub(int n1, - int n2, - int ics, - int isgn, - float** a, - float* t, - int* ip, - float* w) +static void ddxt2d_sub(int n1, + int n2, + int ics, + int isgn, + float** a, + float* t, + int* ip, + float* w) { int i, j; @@ -960,13 +930,8 @@ struct fft2d_arg_t float* w; }; -void xdft2d0_subth(int n1, - int n2, - int icr, - int isgn, - float** a, - int* ip, - float* w) +static void +xdft2d0_subth(int n1, int n2, int icr, int isgn, float** a, int* ip, float* w) { void* xdft2d0_th(void* p); fft2d_thread_t th[FFT2D_MAX_THREADS]; @@ -994,13 +959,8 @@ void xdft2d0_subth(int n1, } } -void cdft2d_subth(int n1, - int n2, - int isgn, - float** a, - float* t, - int* ip, - float* w) +static void +cdft2d_subth(int n1, int n2, int isgn, float** a, float* t, int* ip, float* w) { fft2d_thread_t th[FFT2D_MAX_THREADS]; fft2d_arg_t ag[FFT2D_MAX_THREADS]; @@ -1031,13 +991,8 @@ void cdft2d_subth(int n1, } } -void ddxt2d0_subth(int n1, - int n2, - int ics, - int isgn, - float** a, - int* ip, - float* w) +static void +ddxt2d0_subth(int n1, int n2, int ics, int isgn, float** a, int* ip, float* w) { fft2d_thread_t th[FFT2D_MAX_THREADS]; fft2d_arg_t ag[FFT2D_MAX_THREADS]; @@ -1064,14 +1019,14 @@ void ddxt2d0_subth(int n1, } } -void ddxt2d_subth(int n1, - int n2, - int ics, - int isgn, - float** a, - float* t, - int* ip, - float* w) +static void ddxt2d_subth(int n1, + int n2, + int ics, + int isgn, + float** a, + float* t, + int* ip, + float* w) { fft2d_thread_t th[FFT2D_MAX_THREADS]; fft2d_arg_t ag[FFT2D_MAX_THREADS]; @@ -1103,7 +1058,7 @@ void ddxt2d_subth(int n1, } } -void* xdft2d0_th(void* p) +static void* xdft2d0_th(void* p) { int nthread, n0, n1, n2, icr, isgn, *ip, i; float **a, *w; @@ -1129,7 +1084,7 @@ void* xdft2d0_th(void* p) return (void*) 0; } -void* cdft2d_th(void* p) +static void* cdft2d_th(void* p) { int nthread, n0, n1, n2, isgn, *ip, i, j; float **a, *t, *w; @@ -1199,7 +1154,7 @@ void* cdft2d_th(void* p) return (void*) 0; } -void* ddxt2d0_th(void* p) +static void* ddxt2d0_th(void* p) { int nthread, n0, n1, n2, ics, isgn, *ip, i; float **a, *w; @@ -1225,7 +1180,7 @@ void* ddxt2d0_th(void* p) return (void*) 0; } -void* ddxt2d_th(void* p) +static void* ddxt2d_th(void* p) { int nthread, n0, n1, n2, ics, isgn, *ip, i, j; float **a, *t, *w; diff --git a/src/gpl/src/nesterovBase.cpp b/src/gpl/src/nesterovBase.cpp index 2adf2026f1a..848e1f8677c 100644 --- a/src/gpl/src/nesterovBase.cpp +++ b/src/gpl/src/nesterovBase.cpp @@ -1101,15 +1101,14 @@ NesterovBaseCommon::NesterovBaseCommon( // gCell ptr init nbc_gcells_.reserve(gCellStor_.size()); - for (size_t i = 0; i < gCellStor_.size(); ++i) { - GCell& gCell = gCellStor_[i]; + for (auto& gCell : gCellStor_) { if (!gCell.isInstance()) { continue; } nbc_gcells_.push_back(&gCell); for (Instance* inst : gCell.insts()) { gCellMap_[inst] = &gCell; - db_inst_to_nbc_index_map_[inst->dbInst()] = i; + db_inst_to_nbc_index_map_[inst->dbInst()] = &gCell - &gCellStor_[0]; } } @@ -1557,15 +1556,14 @@ void NesterovBaseCommon::fixPointers() gCellMap_.clear(); db_inst_to_nbc_index_map_.clear(); nbc_gcells_.reserve(gCellStor_.size()); - for (size_t i = 0; i < gCellStor_.size(); ++i) { - GCell& gCell = gCellStor_[i]; + for (auto& gCell : gCellStor_) { if (!gCell.isInstance()) { continue; } nbc_gcells_.push_back(&gCell); for (Instance* inst : gCell.insts()) { gCellMap_[inst] = &gCell; - db_inst_to_nbc_index_map_[inst->dbInst()] = i; + db_inst_to_nbc_index_map_[inst->dbInst()] = &gCell - &gCellStor_[0]; } } diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp index 8ac050af80b..fd971a17efe 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -3672,7 +3672,7 @@ int GlobalRouter::computeNetWirelength(odb::dbNet* db_net) void GlobalRouter::computeWirelength() { - long total_wirelength = 0; + int64_t total_wirelength = 0; for (auto& net_route : routes_) { total_wirelength += computeNetWirelength(net_route.first); } @@ -3906,13 +3906,14 @@ void GlobalRouter::initGrid(int max_layer) num_layers); } -void getViaDims(std::map default_vias, - odb::dbTechLayer* tech_layer, - odb::dbTechLayer* bottom_layer, - int& width_up, - int& prl_up, - int& width_down, - int& prl_down) +static void getViaDims( + std::map default_vias, + odb::dbTechLayer* tech_layer, + odb::dbTechLayer* bottom_layer, + int& width_up, + int& prl_up, + int& width_down, + int& prl_down) { width_up = -1; prl_up = -1; @@ -4504,7 +4505,7 @@ void GlobalRouter::findLayerExtensions(std::vector& layer_extensions) std::vector> spacing_table; obstruct_layer->getTwoWidthsSpacingTable(spacing_table); if (!spacing_table.empty()) { - std::vector last_row = spacing_table.back(); + const std::vector& last_row = spacing_table.back(); uint32_t last_value = last_row.back(); spacing_extension = std::max(last_value, spacing_extension); } diff --git a/src/grt/src/RepairAntennas.cpp b/src/grt/src/RepairAntennas.cpp index 44dc6bf48cb..07795543cf3 100644 --- a/src/grt/src/RepairAntennas.cpp +++ b/src/grt/src/RepairAntennas.cpp @@ -730,9 +730,9 @@ int RepairAntennas::getSegmentsPerLayer( return added_seg_count; } -void getSegmentsWithOverlap(SegmentNode& seg_info, - const std::vector& segs, - odb::dbTechLayer* layer) +static void getSegmentsWithOverlap(SegmentNode& seg_info, + const std::vector& segs, + odb::dbTechLayer* layer) { int index = 0; // Iterate all segment vector to find overlap @@ -871,10 +871,10 @@ void RepairAntennas::findJumperCandidatePositions( } } -void getViaPosition(LayerToSegmentNodeVector& segment_graph, - const GRoute& route, - const SegmentNode& seg_node, - std::unordered_set& via_pos) +static void getViaPosition(LayerToSegmentNodeVector& segment_graph, + const GRoute& route, + const SegmentNode& seg_node, + std::unordered_set& via_pos) { const GSegment& seg = route[seg_node.seg_id]; const int layer_level = seg.init_layer; @@ -990,7 +990,7 @@ bool RepairAntennas::findPosToJumper(const GRoute& route, return (jumper_position != -1); } -odb::Point findSegmentPos(const GSegment& seg) +static odb::Point findSegmentPos(const GSegment& seg) { // Get the middle position of the segment int x = (seg.init_x + seg.final_x) / 2; diff --git a/src/grt/src/fastroute/include/FastRoute.h b/src/grt/src/fastroute/include/FastRoute.h index 5b570c29cff..0ec54cf1a6d 100644 --- a/src/grt/src/fastroute/include/FastRoute.h +++ b/src/grt/src/fastroute/include/FastRoute.h @@ -99,8 +99,8 @@ class FastRouteCore void clear(); void saveCongestion(int iter = -1); void setGridsAndLayers(int x, int y, int nLayers); - void addVCapacity(short verticalCapacity, int layer); - void addHCapacity(short horizontalCapacity, int layer); + void addVCapacity(int16_t verticalCapacity, int layer); + void addHCapacity(int16_t horizontalCapacity, int layer); void setLowerLeft(int x, int y); void setTileSize(int size); void setResistanceAware(bool resistance_aware); @@ -179,17 +179,20 @@ class FastRouteCore void getCongestionGrid(std::vector& congestionGridV, std::vector& congestionGridH); - const std::vector& getVerticalCapacities() { return v_capacity_3D_; } - const std::vector& getHorizontalCapacities() { return h_capacity_3D_; } + const std::vector& getVerticalCapacities() { return v_capacity_3D_; } + const std::vector& getHorizontalCapacities() + { + return h_capacity_3D_; + } int getAvailableResources(int x1, int y1, int x2, int y2, int layer); int getEdgeCapacity(int x1, int y1, int x2, int y2, int layer); const multi_array& getHorizontalEdges3D() { return h_edges_3D_; } const multi_array& getVerticalEdges3D() { return v_edges_3D_; } - void setLastColVCapacity(short cap, int layer) + void setLastColVCapacity(int16_t cap, int layer) { last_col_v_capacity_3D_[layer] = cap; } - void setLastRowHCapacity(short cap, int layer) + void setLastRowHCapacity(int16_t cap, int layer) { last_row_h_capacity_3D_[layer] = cap; } @@ -319,7 +322,7 @@ class FastRouteCore std::vector>& blocked_positions); void routeLShape(const TreeNode& startpoint, const TreeNode& endpoint, - std::vector>& blocked_positions, + std::vector>& blocked_positions, std::vector& new_route); void convertToMazerouteNet(int netID); void setupHeap(int netID, @@ -645,10 +648,10 @@ class FastRouteCore bool regular_x_; bool regular_y_; - std::vector v_capacity_3D_; - std::vector h_capacity_3D_; - std::vector last_col_v_capacity_3D_; - std::vector last_row_h_capacity_3D_; + std::vector v_capacity_3D_; + std::vector h_capacity_3D_; + std::vector last_col_v_capacity_3D_; + std::vector last_row_h_capacity_3D_; std::vector cost_hvh_; // Horizontal first Z std::vector cost_vhv_; // Vertical first Z std::vector cost_h_; // Horizontal segment cost @@ -680,10 +683,10 @@ class FastRouteCore multi_array h_edges_3D_; // The way it is indexed is (Layer, Y, X) multi_array v_edges_3D_; // The way it is indexed is (Layer, Y, X) multi_array corr_edge_; - multi_array parent_x1_; - multi_array parent_y1_; - multi_array parent_x3_; - multi_array parent_y3_; + multi_array parent_x1_; + multi_array parent_y1_; + multi_array parent_x3_; + multi_array parent_y3_; multi_array hv_; multi_array hyper_v_; multi_array hyper_h_; @@ -717,4 +720,6 @@ class FastRouteCore multi_array d2_3D_; }; +extern const char* getNetName(odb::dbNet* db_net); + } // namespace grt diff --git a/src/grt/src/fastroute/src/FastRoute.cpp b/src/grt/src/fastroute/src/FastRoute.cpp index 61f02ae1ab5..b5d00a97bd0 100644 --- a/src/grt/src/fastroute/src/FastRoute.cpp +++ b/src/grt/src/fastroute/src/FastRoute.cpp @@ -205,13 +205,13 @@ void FastRouteCore::setGridsAndLayers(int x, int y, int nLayers) d2_3D_.resize(boost::extents[num_layers_][y_range_][x_range_]); } -void FastRouteCore::addVCapacity(short verticalCapacity, int layer) +void FastRouteCore::addVCapacity(int16_t verticalCapacity, int layer) { v_capacity_3D_[layer - 1] = verticalCapacity; v_capacity_ += v_capacity_3D_[layer - 1]; } -void FastRouteCore::addHCapacity(short horizontalCapacity, int layer) +void FastRouteCore::addHCapacity(int16_t horizontalCapacity, int layer) { h_capacity_3D_[layer - 1] = horizontalCapacity; h_capacity_ += h_capacity_3D_[layer - 1]; @@ -2078,8 +2078,6 @@ void FastRouteCore::computeCongestionInformation() //////////////////////////////////////////////////////////////// -const char* getNetName(odb::dbNet* db_net); - const char* FrNet::getName() const { return getNetName(getDbNet()); diff --git a/src/grt/src/fastroute/src/RSMT.cpp b/src/grt/src/fastroute/src/RSMT.cpp index 4015d972cf5..d44ca194c5e 100644 --- a/src/grt/src/fastroute/src/RSMT.cpp +++ b/src/grt/src/fastroute/src/RSMT.cpp @@ -24,7 +24,7 @@ struct Pnt int o; }; -int orderx(const Pnt* a, const Pnt* b) +static int orderx(const Pnt* a, const Pnt* b) { return a->x < b->x; } diff --git a/src/grt/src/fastroute/src/maze.cpp b/src/grt/src/fastroute/src/maze.cpp index 2f7749243ad..402dd0bbd0f 100644 --- a/src/grt/src/fastroute/src/maze.cpp +++ b/src/grt/src/fastroute/src/maze.cpp @@ -40,13 +40,13 @@ void FastRouteCore::checkAndFixEmbeddedTree(const int net_id) const int num_edges = sttrees_[net_id].num_edges(); // group all edges that crosses the same position - std::unordered_map, + std::unordered_map, std::vector, boost::hash>> position_to_edges_map; auto cmp = [&](int a, int b) { return treeedges[a].len > treeedges[b].len; }; - std::map>, decltype(cmp)> + std::map>, decltype(cmp)> edges_to_blocked_pos_map(cmp); for (int edgeID = 0; edgeID < num_edges; edgeID++) { const TreeEdge* treeedge = &(treeedges[edgeID]); @@ -75,7 +75,7 @@ void FastRouteCore::checkAndFixEmbeddedTree(const int net_id) // fix the longest edge and break the loop if (!edges_to_blocked_pos_map.empty()) { int edge = edges_to_blocked_pos_map.begin()->first; - std::vector>& blocked_positions + std::vector>& blocked_positions = edges_to_blocked_pos_map.begin()->second; fixOverlappingEdge(net_id, edge, blocked_positions); } @@ -126,9 +126,10 @@ void FastRouteCore::fixOverlappingEdge( TreeEdge* treeedge = &(sttrees_[net_id].edges[edge]); auto& treenodes = sttrees_[net_id].nodes; - auto sort_by_x = [](std::pair a, std::pair b) { - return a.first < b.first; - }; + auto sort_by_x + = [](std::pair a, std::pair b) { + return a.first < b.first; + }; std::ranges::stable_sort(blocked_positions, sort_by_x); @@ -180,15 +181,15 @@ void FastRouteCore::fixOverlappingEdge( void FastRouteCore::routeLShape( const TreeNode& startpoint, const TreeNode& endpoint, - std::vector>& blocked_positions, + std::vector>& blocked_positions, std::vector& new_route) { new_route.push_back({startpoint.x, startpoint.y, -1}); - short first_x; - short first_y; + int16_t first_x; + int16_t first_y; if (blocked_positions.front().second == blocked_positions.back().second) { // blocked positions are horizontally aligned - short y; + int16_t y; // using first_x variable to avoid duplicated points if (startpoint.y != blocked_positions[0].second) { y = startpoint.y; @@ -204,7 +205,7 @@ void FastRouteCore::routeLShape( first_x++; } } - for (short x = first_x; x <= endpoint.x; x++) { + for (int16_t x = first_x; x <= endpoint.x; x++) { new_route.push_back({x, y, -1}); } if (y < endpoint.y) { @@ -222,7 +223,7 @@ void FastRouteCore::routeLShape( } } else { // blocked positions are vertically aligned - short x; + int16_t x; if (startpoint.x != blocked_positions[0].first) { x = startpoint.x; // point (startpoint.x, startpoint.y) already @@ -240,11 +241,11 @@ void FastRouteCore::routeLShape( } } if (startpoint.y < endpoint.y) { - for (short y = first_y; y <= endpoint.y; y++) { + for (int16_t y = first_y; y <= endpoint.y; y++) { new_route.push_back({x, y, -1}); } } else { - for (short y = first_y; y >= endpoint.y; y--) { + for (int16_t y = first_y; y >= endpoint.y; y--) { new_route.push_back({x, y, -1}); } } diff --git a/src/grt/src/fastroute/src/utility.cpp b/src/grt/src/fastroute/src/utility.cpp index bcebb27c1c8..990a1ddd042 100644 --- a/src/grt/src/fastroute/src/utility.cpp +++ b/src/grt/src/fastroute/src/utility.cpp @@ -641,7 +641,7 @@ void FastRouteCore::assignEdge(const int netID, const int n1a = treeedge->n1a; const int n2a = treeedge->n2a; - std::vector> gridD; + std::vector> gridD; gridD.resize(num_layers_); for (int i = 0; i < num_layers_; i++) { gridD[i].resize(treeedge->route.routelen + 1); diff --git a/src/gui/include/gui/gui.h b/src/gui/include/gui/gui.h index 1303654923b..41c82696f9f 100644 --- a/src/gui/include/gui/gui.h +++ b/src/gui/include/gui/gui.h @@ -166,16 +166,19 @@ class Painter virtual Color getPenColor() = 0; // Set the pen to whatever the user has chosen for this layer - virtual void setPen(odb::dbTechLayer* layer, bool cosmetic = false) = 0; + virtual void setPen(odb::dbTechLayer* layer, bool cosmetic) = 0; + void setPen(odb::dbTechLayer* layer) { setPen(layer, false); } // Set the pen to an RGBA value - virtual void setPen(const Color& color, bool cosmetic = false, int width = 1) - = 0; + virtual void setPen(const Color& color, bool cosmetic, int width) = 0; + void setPen(const Color& color, bool cosmetic) { setPen(color, cosmetic, 1); } + void setPen(const Color& color) { setPen(color, false); } virtual void setPenWidth(int width) = 0; // Set the brush to whatever the user has chosen for this layer // The alpha value may be overridden - virtual void setBrush(odb::dbTechLayer* layer, int alpha = -1) = 0; + virtual void setBrush(odb::dbTechLayer* layer, int alpha) = 0; + void setBrush(odb::dbTechLayer* layer) { setBrush(layer, -1); } // Set the brush to whatever the user has chosen for this layer enum Brush @@ -186,7 +189,8 @@ class Painter kCross, kDots }; - virtual void setBrush(const Color& color, const Brush& style = kSolid) = 0; + virtual void setBrush(const Color& color, const Brush& style) = 0; + void setBrush(const Color& color) { setBrush(color, Brush::kSolid); } virtual void setFont(const Font& font) = 0; @@ -253,8 +257,12 @@ class Painter int y, Anchor anchor, const std::string& s, - bool rotate_90 = false) + bool rotate_90) = 0; + void drawString(int x, int y, Anchor anchor, const std::string& s) + { + drawString(x, y, anchor, s, false); + } virtual odb::Rect stringBoundaries(int x, int y, Anchor anchor, @@ -265,9 +273,17 @@ class Painter int y0, int x1, int y1, - bool euclidian = true, - const std::string& label = "") + bool euclidian, + const std::string& label) = 0; + void drawRuler(int x0, int y0, int x1, int y1, bool euclidian) + { + drawRuler(x0, y0, x1, y1, euclidian, ""); + } + void drawRuler(int x0, int y0, int x1, int y1) + { + drawRuler(x0, y0, x1, y1, true); + } // Draw a line with coordinates in DBU with the current pen void drawLine(int xl, int yl, int xh, int yh) @@ -599,6 +615,7 @@ class Renderer if (settings.count(key) == 1) { try { value = std::get(settings.at(key)); + // NOLINTNEXTLINE(bugprone-empty-catch) } catch (const std::bad_variant_access&) { // Stay with current value } diff --git a/src/gui/src/cmdInputWidget.h b/src/gui/src/cmdInputWidget.h index fb4cddf2d4b..a3ec369bd37 100644 --- a/src/gui/src/cmdInputWidget.h +++ b/src/gui/src/cmdInputWidget.h @@ -42,10 +42,13 @@ class CmdInputWidget : public QPlainTextEdit void addCommandToOutput(const QString& cmd); public slots: - virtual void executeCommand(const QString& cmd, - bool echo = true, - bool silent = false) - = 0; + virtual void executeCommand(const QString& cmd, bool echo, bool silent) = 0; + + void executeCommand(const QString& cmd, bool echo) + { + executeCommand(cmd, echo, false); + } + void executeCommand(const QString& cmd) { executeCommand(cmd, true); } private slots: void updateSize(); diff --git a/src/gui/src/dbDescriptors.cpp b/src/gui/src/dbDescriptors.cpp index facd840b390..4a6b01ed640 100644 --- a/src/gui/src/dbDescriptors.cpp +++ b/src/gui/src/dbDescriptors.cpp @@ -2726,9 +2726,9 @@ Descriptor::Editors DbBlockageDescriptor::getEditors( blockage->setMaxDensity(density); return true; } - } catch (std::out_of_range&) { + } catch (std::out_of_range&) { // NOLINT(bugprone-empty-catch) // catch poorly formatted string - } catch (std::logic_error&) { + } catch (std::logic_error&) { // NOLINT(bugprone-empty-catch) // catch poorly formatted string } } diff --git a/src/gui/src/displayControls.h b/src/gui/src/displayControls.h index 7991a5c7e93..23dbec1e640 100644 --- a/src/gui/src/displayControls.h +++ b/src/gui/src/displayControls.h @@ -121,11 +121,10 @@ class DisplayControlModel : public QStandardItemModel public: DisplayControlModel(int user_data_item_idx, QWidget* parent = nullptr); - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex& index, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const override; + int role) const override; private: const int user_data_item_idx_; diff --git a/src/gui/src/drcWidget.cpp b/src/gui/src/drcWidget.cpp index 9ec695a71e2..4e1d89246e1 100644 --- a/src/gui/src/drcWidget.cpp +++ b/src/gui/src/drcWidget.cpp @@ -370,7 +370,8 @@ void DRCWidget::loadReport(const QString& filename) "Unable to determine type of {}", filename.toStdString()); } - } catch (std::runtime_error&) { + } catch (std::runtime_error& e) { + logger_->warn(utl::GUI, 110, "Failed to load: {}", e.what()); } // catch errors if (category != nullptr) { diff --git a/src/gui/src/inspector.h b/src/gui/src/inspector.h index ee365ee6e0b..f92da323921 100644 --- a/src/gui/src/inspector.h +++ b/src/gui/src/inspector.h @@ -83,8 +83,7 @@ class SelectedItemModel : public QStandardItemModel const QColor& editable, QObject* parent = nullptr); - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex& index, int role) const override; const QColor& getSelectableColor() { return selectable_item_; } const QColor& getEditableColor() { return editable_item_; } diff --git a/src/gui/src/mainWindow.cpp b/src/gui/src/mainWindow.cpp index 591ce031839..a21c7a6f25e 100644 --- a/src/gui/src/mainWindow.cpp +++ b/src/gui/src/mainWindow.cpp @@ -1937,7 +1937,9 @@ void MainWindow::saveDesign() try { ord::OpenRoad::openRoad()->writeDb(file.toStdString().c_str()); - } catch (const std::exception&) { + } catch (const std::exception& e) { + QMessageBox::warning( + this, "Save Error", QString("Db save failed: %1").arg(e.what())); } } diff --git a/src/gui/src/painter.h b/src/gui/src/painter.h index e0f5d741196..4a8c812429e 100644 --- a/src/gui/src/painter.h +++ b/src/gui/src/painter.h @@ -40,20 +40,21 @@ class GuiPainter : public Painter return Color(color.red(), color.green(), color.blue(), color.alpha()); } - void setPen(odb::dbTechLayer* layer, bool cosmetic = false) override + void setPen(odb::dbTechLayer* layer, bool cosmetic) override { QPen pen(getOptions()->color(layer)); pen.setCosmetic(cosmetic); painter_->setPen(pen); } - void setPen(const Color& color, bool cosmetic = false, int width = 1) override + void setPen(const Color& color, bool cosmetic, int width) override { QPen pen(QColor(color.r, color.g, color.b, color.a)); pen.setCosmetic(cosmetic); pen.setWidth(width); painter_->setPen(pen); } + using Painter::setPen; void setPenWidth(int width) override { @@ -63,7 +64,7 @@ class GuiPainter : public Painter painter_->setPen(pen); } - void setBrush(odb::dbTechLayer* layer, int alpha = -1) override + void setBrush(odb::dbTechLayer* layer, int alpha) override { QColor color = getOptions()->color(layer); Qt::BrushStyle brush_pattern = getOptions()->pattern(layer); @@ -73,7 +74,7 @@ class GuiPainter : public Painter painter_->setBrush(QBrush(color, brush_pattern)); } - void setBrush(const Color& color, const Brush& style = Brush::kSolid) override + void setBrush(const Color& color, const Brush& style) override { const QColor qcolor(color.r, color.g, color.b, color.a); @@ -104,6 +105,7 @@ class GuiPainter : public Painter painter_->setBrush(QBrush(qcolor, brush_pattern)); } + using Painter::setBrush; void setFont(const Font& font) override; @@ -173,7 +175,8 @@ class GuiPainter : public Painter int y, Anchor anchor, const std::string& s, - bool rotate_90 = false) override; + bool rotate_90) override; + using Painter::drawString; odb::Rect stringBoundaries(int x, int y, @@ -196,8 +199,8 @@ class GuiPainter : public Painter int y0, int x1, int y1, - bool euclidian = true, - const std::string& label = "") override + bool euclidian, + const std::string& label) override { if (euclidian) { drawRuler(x0, y0, x1, y1, label); @@ -214,6 +217,7 @@ class GuiPainter : public Painter drawRuler(mid_pt.x(), mid_pt.y(), x1, y1, y_label); } } + using Painter::drawRuler; QPainter* getPainter() { return painter_; } diff --git a/src/gui/src/selectHighlightWindow.h b/src/gui/src/selectHighlightWindow.h index 055e2367727..479cd7c2f0a 100644 --- a/src/gui/src/selectHighlightWindow.h +++ b/src/gui/src/selectHighlightWindow.h @@ -33,15 +33,13 @@ class SelectionModel : public QAbstractTableModel public: SelectionModel(const SelectionSet& objs); - int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex& parent - = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + int role) const Q_DECL_OVERRIDE; const Selected* getItemAt(int idx) const { return table_data_[idx]; } @@ -58,15 +56,13 @@ class HighlightModel : public QAbstractTableModel public: HighlightModel(const HighlightSet& objs); - int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex& parent - = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + int role) const Q_DECL_OVERRIDE; const Selected* getItemAt(int idx) const { return table_data_[idx].second; } void populateModel(); diff --git a/src/gui/src/staGui.h b/src/gui/src/staGui.h index 2942b662f3e..29f7356d71e 100644 --- a/src/gui/src/staGui.h +++ b/src/gui/src/staGui.h @@ -85,15 +85,15 @@ class TimingPathsModel : public QAbstractTableModel STAGuiInterface* sta, QObject* parent = nullptr); - int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex& parent - = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; + int rowCount() const { return rowCount({}); } + int columnCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; + int columnCount() const { return columnCount({}); } - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + int role) const Q_DECL_OVERRIDE; TimingPath* getPathAt(const QModelIndex& index) const; @@ -151,15 +151,14 @@ class TimingPathDetailModel : public QAbstractTableModel sta::dbSta* sta, QObject* parent = nullptr); - int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex& parent - = QModelIndex()) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; + int rowCount() const { return rowCount({}); } + int columnCount(const QModelIndex& parent) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + int role) const Q_DECL_OVERRIDE; Qt::ItemFlags flags(const QModelIndex& index) const Q_DECL_OVERRIDE; TimingPath* getPath() const { return path_; } diff --git a/src/gui/src/tclCmdInputWidget.h b/src/gui/src/tclCmdInputWidget.h index aee82c7428c..2ddc3f6fc1b 100644 --- a/src/gui/src/tclCmdInputWidget.h +++ b/src/gui/src/tclCmdInputWidget.h @@ -50,10 +50,11 @@ class TclCmdInputWidget : public CmdInputWidget void readSettings(QSettings* settings); void writeSettings(QSettings* settings); + // Bring the overloads into scope. + using CmdInputWidget::executeCommand; + public slots: - void executeCommand(const QString& cmd, - bool echo = true, - bool silent = false) override; + void executeCommand(const QString& cmd, bool echo, bool silent) override; private slots: void updateHighlighting(); diff --git a/src/odb/include/odb/geom.h b/src/odb/include/odb/geom.h index cc4e2c82bd3..f8a4ad716e4 100644 --- a/src/odb/include/odb/geom.h +++ b/src/odb/include/odb/geom.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -1001,7 +1002,7 @@ inline int Oct::yMax() const inline std::vector Oct::getPoints() const { OCT_DIR dir = getDir(); - int B = ceil((A_ * 2) / (sqrt(2))) - A_; + int B = ceil((A_ * 2) / std::numbers::sqrt2) - A_; std::vector points(9); points[0] = points[8] = Point(center_low_.getX() - B, center_low_.getY() - A_); // low oct (-B,-A) diff --git a/src/odb/src/def/cdef/defrReader.h b/src/odb/src/def/cdef/defrReader.h index be5f51cbff8..035e5329dc6 100644 --- a/src/odb/src/def/cdef/defrReader.h +++ b/src/odb/src/def/cdef/defrReader.h @@ -33,6 +33,7 @@ #ifndef CDEFRREADER_H #define CDEFRREADER_H +#include #include #include "defiTypedefs.h" @@ -598,7 +599,7 @@ EXTERN void defrSetUnusedCallbacks(defrVoidCbkFnType func); /* Return the current line number in the input file. */ EXTERN int defrLineNumber(); -EXTERN long long defrLongLineNumber(); +EXTERN int64_t defrLongLineNumber(); /* Routine to set the message logging routine for errors */ using DEFI_LOG_FUNCTION = void (*)(const char*); @@ -627,7 +628,7 @@ using DEFI_LINE_NUMBER_FUNCTION = void (*)(int); EXTERN void defrSetLineNumberFunction(DEFI_LINE_NUMBER_FUNCTION p0); /* Routine to set the line number of the file that is parsing routine (takes */ -using DEFI_LONG_LINE_NUMBER_FUNCTION = void (*)(long long); +using DEFI_LONG_LINE_NUMBER_FUNCTION = void (*)(int64_t); EXTERN void defrSetLongLineNumberFunction(DEFI_LONG_LINE_NUMBER_FUNCTION p0); /* Set the number of lines before calling the line function callback routine */ @@ -657,7 +658,7 @@ EXTERN void defrSetMagicCommentString(char* p0); EXTERN void defrDisablePropStrProcess(); /* Testing purposes only */ -EXTERN void defrSetNLines(long long n); +EXTERN void defrSetNLines(int64_t n); /* Routine to set the max number of warnings for a perticular section */ diff --git a/src/odb/src/def/cdef/xdefrReader.cpp b/src/odb/src/def/cdef/xdefrReader.cpp index ef8b3ecc091..5cf84de7c16 100644 --- a/src/odb/src/def/cdef/xdefrReader.cpp +++ b/src/odb/src/def/cdef/xdefrReader.cpp @@ -33,6 +33,7 @@ #define EXTERN extern "C" +#include #include #include "defrReader.h" @@ -1176,7 +1177,7 @@ int defrLineNumber() return DefParser::defrLineNumber(); } -long long defrLongLineNumber() +int64_t defrLongLineNumber() { return DefParser::defrLongLineNumber(); } @@ -1256,7 +1257,7 @@ void defrDisablePropStrProcess() DefParser::defrDisablePropStrProcess(); } -void defrSetNLines(long long n) +void defrSetNLines(int64_t n) { DefParser::defrSetNLines(n); } diff --git a/src/odb/src/def/def/def_keywords.cpp b/src/odb/src/def/def/def_keywords.cpp index b0ed41f8d67..0bda0bacaee 100644 --- a/src/odb/src/def/def/def_keywords.cpp +++ b/src/odb/src/def/def/def_keywords.cpp @@ -34,6 +34,8 @@ /* and other keywords */ #include +#include +#include #include #include #include @@ -238,7 +240,7 @@ int defrData::DefGetTokenFromStack(char* s) return false; /* if we get here, we ran out of input levels */ } -void defrData::print_lines(long long lines) +void defrData::print_lines(int64_t lines) { if (lines % settings->defiDeltaNumberLines) { return; @@ -256,12 +258,12 @@ void defrData::print_lines(long long lines) } } -const char* defrData::lines2str(long long lines) +const char* defrData::lines2str(int64_t lines) { #ifdef _WIN32 sprintf(lineBuffer, "%I64d", lines); #else - sprintf(lineBuffer, "%lld", lines); + sprintf(lineBuffer, "%" PRId64, lines); #endif return lineBuffer; @@ -276,7 +278,7 @@ void defrData::IncCurPos(char** curPos, char** buffer, int* bufferSize) return; } - long offset = *curPos - *buffer; + int64_t offset = *curPos - *buffer; *bufferSize *= 2; *buffer = (char*) realloc(*buffer, *bufferSize); @@ -432,6 +434,9 @@ void defrData::StoreAlias() std::string so_far; /* contains alias contents as we build it */ if (strcmp(line, "=") != 0) { + free(aname); + free(line); + free(uc_line); defError(6000, "Expecting '='"); return; } @@ -443,6 +448,9 @@ void defrData::StoreAlias() for (i = 0; i < tokenSize - 1; i++) { int ch = GETC(); if (ch == EOF) { + free(aname); + free(line); + free(uc_line); defError(6001, "End of file in &ALIAS"); return; } diff --git a/src/odb/src/def/def/defiNet.cpp b/src/odb/src/def/def/defiNet.cpp index 5e8ddcf6e2e..9f86be198fd 100644 --- a/src/odb/src/def/def/defiNet.cpp +++ b/src/odb/src/def/def/defiNet.cpp @@ -29,6 +29,7 @@ #include "defiNet.hpp" +#include #include #include #include @@ -343,7 +344,7 @@ int defiSubnet::isCover() const return (int) (isCover_); } -void defiSubnet::bumpName(long long size) +void defiSubnet::bumpName(int64_t size) { if (name_) { free(name_); @@ -353,13 +354,13 @@ void defiSubnet::bumpName(long long size) name_[0] = '\0'; } -void defiSubnet::bumpPins(long long size) +void defiSubnet::bumpPins(int64_t size) { char** newInstances = (char**) malloc(sizeof(char*) * size); char** newPins = (char**) malloc(sizeof(char*) * size); char* newMusts = (char*) malloc(size); char* newSyn = (char*) malloc(size); - long long i; + int64_t i; if (instances_) { for (i = 0; i < pinsAllocated_; i++) { @@ -512,9 +513,9 @@ int defiSubnet::numPaths() const } // WMD -- this will be removed after the next release -void defiSubnet::bumpPaths(long long size) +void defiSubnet::bumpPaths(int64_t size) { - long long i; + int64_t i; defiPath** newPaths = new defiPath*[size]; for (i = 0; i < numPaths_; i++) { @@ -741,9 +742,9 @@ void defiShield::clear() } } -void defiShield::bumpPaths(long long size) +void defiShield::bumpPaths(int64_t size) { - long long i; + int64_t i; defiPath** newPaths = new defiPath*[size]; @@ -889,9 +890,9 @@ void defiWire::clear() } } -void defiWire::bumpPaths(long long size) +void defiWire::bumpPaths(int64_t size) { - long long i; + int64_t i; defiPath** newPaths = new defiPath*[size]; for (i = 0; i < numPaths_; i++) { @@ -1702,7 +1703,7 @@ void defiNet::print(FILE* f) const } } -void defiNet::bumpName(long long size) +void defiNet::bumpName(int64_t size) { if (name_) { free(name_); @@ -1712,13 +1713,13 @@ void defiNet::bumpName(long long size) name_[0] = '\0'; } -void defiNet::bumpPins(long long size) +void defiNet::bumpPins(int64_t size) { char** newInstances = (char**) malloc(sizeof(char*) * size); char** newPins = (char**) malloc(sizeof(char*) * size); char* newMusts = (char*) malloc(size); char* newSyn = (char*) malloc(size); - long long i; + int64_t i; if (instances_) { for (i = 0; i < pinsAllocated_; i++) { @@ -1740,13 +1741,13 @@ void defiNet::bumpPins(long long size) pinsAllocated_ = size; } -void defiNet::bumpProps(long long size) +void defiNet::bumpProps(int64_t size) { char** newNames = (char**) malloc(sizeof(char*) * size); char** newValues = (char**) malloc(sizeof(char*) * size); double* newDValues = (double*) malloc(sizeof(double) * size); char* newTypes = (char*) malloc(sizeof(char) * size); - long long i; + int64_t i; if (propNames_) { for (i = 0; i < numProps_; i++) { @@ -1768,7 +1769,7 @@ void defiNet::bumpProps(long long size) propsAllocated_ = size; } -void defiNet::bumpSubnets(long long size) +void defiNet::bumpSubnets(int64_t size) { defiSubnet** newSubnets = (defiSubnet**) malloc(sizeof(defiSubnet*) * size); int i; @@ -2307,9 +2308,9 @@ const char* defiNet::nonDefaultRule() const } // WMD -- this will be removed by the next release -void defiNet::bumpPaths(long long size) +void defiNet::bumpPaths(int64_t size) { - long long i; + int64_t i; defiPath** newPaths = new defiPath*[size]; @@ -2366,10 +2367,10 @@ const defiWire* defiNet::wire(int index) const return nullptr; } -void defiNet::bumpShieldNets(long long size) +void defiNet::bumpShieldNets(int64_t size) { char** newShieldNets = (char**) malloc(sizeof(char*) * size); - long long i; + int64_t i; if (shieldNet_) { for (i = 0; i < shieldNetsAllocated_; i++) { diff --git a/src/odb/src/def/def/defiNet.hpp b/src/odb/src/def/def/defiNet.hpp index 5d31d4463b2..ba4336b4d19 100644 --- a/src/odb/src/def/def/defiNet.hpp +++ b/src/odb/src/def/def/defiNet.hpp @@ -30,6 +30,7 @@ #ifndef defiNet_h #define defiNet_h +#include #include #include "defiKRDefs.hpp" @@ -69,7 +70,7 @@ class defiWire defiPath* path(int index); const defiPath* path(int index) const; - void bumpPaths(long long size); + void bumpPaths(int64_t size); protected: defrData* defData; @@ -77,7 +78,7 @@ class defiWire char* type_{nullptr}; char* wireShieldName_{nullptr}; // It only set from specialnet SHIELD, 5.4 int numPaths_{0}; - long long pathsAllocated_{0}; + int64_t pathsAllocated_{0}; }; class defiSubnet @@ -130,32 +131,32 @@ class defiSubnet defiWire* wire(int index); const defiWire* wire(int index) const; - void bumpName(long long size); - void bumpPins(long long size); - void bumpPaths(long long size); + void bumpName(int64_t size); + void bumpPins(int64_t size); + void bumpPaths(int64_t size); void clear(); protected: - char* name_; // name. - int nameSize_; // allocated size of name. - int numPins_; // number of pins used in array. - long long pinsAllocated_; // number of pins allocated in array. - char** instances_; // instance names for connections - char** pins_; // pin names for connections - char* synthesized_; // synthesized flags for pins - char* musts_; // must-join flags + char* name_; // name. + int nameSize_; // allocated size of name. + int numPins_; // number of pins used in array. + int64_t pinsAllocated_; // number of pins allocated in array. + char** instances_; // instance names for connections + char** pins_; // pin names for connections + char* synthesized_; // synthesized flags for pins + char* musts_; // must-join flags // WMD -- the following will be removed by the next release char isFixed_; // net type char isRouted_; char isCover_; - defiPath** paths_; // paths for this subnet - int numPaths_; // number of paths used - long long pathsAllocated_; // allocated size of paths array + defiPath** paths_; // paths for this subnet + int numPaths_; // number of paths used + int64_t pathsAllocated_; // allocated size of paths array - int numWires_; // number of wires defined in the subnet - long long wiresAllocated_; // number of wires allocated in the subnet - defiWire** wires_; // this replace the paths + int numWires_; // number of wires defined in the subnet + int64_t wiresAllocated_; // number of wires allocated in the subnet + defiWire** wires_; // this replace the paths char* nonDefaultRule_; defrData* defData; @@ -220,12 +221,12 @@ class defiShield defiPath* path(int index); const defiPath* path(int index) const; - void bumpPaths(long long size); + void bumpPaths(int64_t size); protected: char* name_; int numPaths_; - long long pathsAllocated_; + int64_t pathsAllocated_; defiPath** paths_; defrData* defData; @@ -441,12 +442,12 @@ class defiNet // Debug printing void print(FILE* f) const; - void bumpName(long long size); - void bumpPins(long long size); - void bumpProps(long long size); - void bumpSubnets(long long size); - void bumpPaths(long long size); - void bumpShieldNets(long long size); + void bumpName(int64_t size); + void bumpPins(int64_t size); + void bumpProps(int64_t size); + void bumpSubnets(int64_t size); + void bumpPaths(int64_t size); + void bumpShieldNets(int64_t size); // The method freeWire() is added is user select to have a callback // per wire within a net This is an internal method and is not public @@ -459,16 +460,16 @@ class defiNet void clearVia(); protected: - char* name_; // name. - int nameSize_; // allocated size of name. - int numPins_; // number of pins used in array. - long long pinsAllocated_; // number of pins allocated in array. - char** instances_; // instance names for connections - char** pins_; // pin names for connections - char* musts_; // must-join flags for pins - char* synthesized_; // synthesized flags for pins - int weight_; // net weight - char hasWeight_; // flag for optional weight + char* name_; // name. + int nameSize_; // allocated size of name. + int numPins_; // number of pins used in array. + int64_t pinsAllocated_; // number of pins allocated in array. + char** instances_; // instance names for connections + char** pins_; // pin names for connections + char* musts_; // must-join flags for pins + char* synthesized_; // synthesized flags for pins + int weight_; // net weight + char hasWeight_; // flag for optional weight // WMD -- the following will be removed by the nex release char isFixed_; // net type @@ -484,11 +485,11 @@ class defiNet double* propDValues_; // Prop values in numbers! char* propTypes_; // Prop types, 'I' - Integer, 'R' - Real, 'S' - String - long long propsAllocated_; // allocated size of props array - int numSubnets_; // num of subnets in array - defiSubnet** subnets_; // Prop names - long long subnetsAllocated_; // allocated size of props array - double cap_; // cap value + int64_t propsAllocated_; // allocated size of props array + int numSubnets_; // num of subnets in array + defiSubnet** subnets_; // Prop names + int64_t subnetsAllocated_; // allocated size of props array + double cap_; // cap value char* source_; int fixedbump_; // 5.4.1 double frequency_; // 5.4.1 @@ -499,22 +500,22 @@ class defiNet int style_; // WMD -- the following will be removed by the nex release - defiPath** paths_; // paths for this subnet - int numPaths_; // number of paths used - long long pathsAllocated_; // allocated size of paths array + defiPath** paths_; // paths for this subnet + int numPaths_; // number of paths used + int64_t pathsAllocated_; // allocated size of paths array double voltage_; - int numWires_; // number of wires defined in the net - long long wiresAllocated_; // allocated size of wire paths array - defiWire** wires_; // this replace the paths + int numWires_; // number of wires defined in the net + int64_t wiresAllocated_; // allocated size of wire paths array + defiWire** wires_; // this replace the paths - long long widthsAllocated_; + int64_t widthsAllocated_; int numWidths_; char** wlayers_; double* wdist_; - long long spacingAllocated_; + int64_t spacingAllocated_; int numSpacing_; char** slayers_; double* sdist_; @@ -523,30 +524,30 @@ class defiNet int xTalk_; int numVpins_; - long long vpinsAllocated_; + int64_t vpinsAllocated_; defiVpin** vpins_; - int numShields_; // number of SHIELD paths used - long long shieldsAllocated_; // allocated size of SHIELD paths array - defiShield** shields_; // SHIELD data - int numNoShields_; // number of NOSHIELD paths used + int numShields_; // number of SHIELD paths used + int64_t shieldsAllocated_; // allocated size of SHIELD paths array + defiShield** shields_; // SHIELD data + int numNoShields_; // number of NOSHIELD paths used - int numShieldNet_; // number of SHIELDNETS used in array. - long long shieldNetsAllocated_; // number of SHIELDNETS allocated in array. - char** shieldNet_; // name of the SHIELDNET + int numShieldNet_; // number of SHIELDNETS used in array. + int64_t shieldNetsAllocated_; // number of SHIELDNETS allocated in array. + char** shieldNet_; // name of the SHIELDNET int numPolys_; // 5.6 char** polygonNames_; // 5.6 layerName for POLYGON - long long polysAllocated_; // 5.6 + int64_t polysAllocated_; // 5.6 struct defiPoints** polygons_; // 5.6 int* polyMasks_; char** polyRouteStatus_; char** polyShapeTypes_; char** polyRouteStatusShieldNames_; - int numRects_; // 5.6 - long long rectsAllocated_; // 5.6 - char** rectNames_; // 5.6 + int numRects_; // 5.6 + int64_t rectsAllocated_; // 5.6 + char** rectNames_; // 5.6 int* xl_; int* yl_; int* xh_; @@ -559,7 +560,7 @@ class defiNet struct defiPoints** viaPts_; // 5.8 char** viaNames_; int numPts_; - long long ptsAllocated_; + int64_t ptsAllocated_; int* viaOrients_; int* viaMasks_; char** viaRouteStatus_; diff --git a/src/odb/src/def/def/defrData.hpp b/src/odb/src/def/def/defrData.hpp index f8f40738a76..11c8919fa9e 100644 --- a/src/odb/src/def/def/defrData.hpp +++ b/src/odb/src/def/def/defrData.hpp @@ -27,6 +27,7 @@ // ***************************************************************************** // ***************************************************************************** +#include #include #include #include @@ -112,8 +113,8 @@ class defrData void UNGETC(char ch); char* ringCopy(const char* string); int DefGetTokenFromStack(char* s); - inline void print_lines(long long lines); - const char* lines2str(long long lines); + inline void print_lines(int64_t lines); + const char* lines2str(int64_t lines); static inline void IncCurPos(char** curPos, char** buffer, int* bufferSize); int DefGetToken(char** buffer, int* bufferSize); static void uc_array(char* source, char* dest); @@ -274,7 +275,7 @@ class defrData int input_level{-1}; char* last{nullptr}; // points to the last valid char in the buffer, or null int new_is_keyword{0}; - long long nlines{1}; + int64_t nlines{1}; char* rowName{nullptr}; // to hold the rowName for message int iOTimingWarnings{0}; char* magic; diff --git a/src/odb/src/def/def/defrReader.cpp b/src/odb/src/def/def/defrReader.cpp index 1b89bf00a7b..1c1d8049380 100644 --- a/src/odb/src/def/def/defrReader.cpp +++ b/src/odb/src/def/def/defrReader.cpp @@ -29,6 +29,7 @@ #include "defrReader.hpp" +#include #include #include #include @@ -2191,7 +2192,7 @@ void defrDisablePropStrProcess() defContext.settings->DisPropStrProcess = 1; } -void defrSetNLines(long long n) +void defrSetNLines(int64_t n) { defrData* defData = defContext.data; @@ -2209,7 +2210,7 @@ int defrLineNumber() return 0; } -long long defrLongLineNumber() +int64_t defrLongLineNumber() { // Compatibility feature: in old versions the translators, // the function can be called before defData initialization. @@ -2218,7 +2219,7 @@ long long defrLongLineNumber() return defContext.data->nlines; } - return (long long) 0; + return (int64_t) 0; } END_DEF_PARSER_NAMESPACE diff --git a/src/odb/src/def/def/defrReader.hpp b/src/odb/src/def/def/defrReader.hpp index 6adad5d4f8e..a173295071b 100644 --- a/src/odb/src/def/def/defrReader.hpp +++ b/src/odb/src/def/def/defrReader.hpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -628,7 +629,7 @@ extern void defrSetUnusedCallbacks(defrVoidCbkFnType func); // Return the current line number in the input file. extern int defrLineNumber(); -extern long long defrLongLineNumber(); +extern int64_t defrLongLineNumber(); // Routine to set the message logging routine for errors #ifndef DEFI_LOG_FUNCTION @@ -675,8 +676,8 @@ using DEFI_LINE_NUMBER_FUNCTION = void (*)(int); extern void defrSetLineNumberFunction(DEFI_LINE_NUMBER_FUNCTION); // Routine to set the line number of the file that is parsing routine (takes -// long long) -using DEFI_LONG_LINE_NUMBER_FUNCTION = void (*)(long long); +// int64_t) +using DEFI_LONG_LINE_NUMBER_FUNCTION = void (*)(int64_t); extern void defrSetLongLineNumberFunction(DEFI_LONG_LINE_NUMBER_FUNCTION); // Routine to set the line number of the file that is parsing routine (takes @@ -685,9 +686,9 @@ using DEFI_CONTEXT_LINE_NUMBER_FUNCTION = void (*)(defiUserData userData, int); extern void defrSetContextLineNumberFunction(DEFI_CONTEXT_LINE_NUMBER_FUNCTION); // Routine to set the line number of the file that is parsing routine (takes -// long long Used in re-enterable environment. +// int64_t Used in re-enterable environment. using DEFI_CONTEXT_LONG_LINE_NUMBER_FUNCTION - = void (*)(defiUserData userData, long long); + = void (*)(defiUserData userData, int64_t); extern void defrSetContextLongLineNumberFunction( DEFI_CONTEXT_LONG_LINE_NUMBER_FUNCTION); @@ -717,7 +718,7 @@ extern void defrSetMagicCommentString(char*); extern void defrDisablePropStrProcess(); // Testing purposes only -extern void defrSetNLines(long long n); +extern void defrSetNLines(int64_t n); // Routine to set the max number of warnings for a perticular section diff --git a/src/odb/src/def/defdiff/diffDefRW.cpp b/src/odb/src/def/defdiff/diffDefRW.cpp index d48b24e3cec..4b091f2600c 100644 --- a/src/odb/src/def/defdiff/diffDefRW.cpp +++ b/src/odb/src/def/defdiff/diffDefRW.cpp @@ -31,6 +31,7 @@ // routines and write it out to a temporary file. #include +#include #include #include #include @@ -81,9 +82,9 @@ void checkType(defrCallbackType_e c) // This function will make sure it round up for all the machine double checkDouble(double num) { - long tempNum; + int64_t tempNum; if ((num > 1000004) || (num < -1000004)) { - tempNum = (long) num; + tempNum = (int64_t) num; if ((tempNum % 5) == 0) { return num + 3; } @@ -1921,7 +1922,7 @@ int cls(defrCallbackType_e c, void* cl, defiUserData ud) --numObjs; break; case defrDefaultCapCbkType: - i = (unsigned long long) cl; + i = (uint64_t) cl; fprintf(fout, "DEFAULTCAP %d\n", i); numObjs = i; break; diff --git a/src/odb/src/def/defrw/defrw.cpp b/src/odb/src/def/defrw/defrw.cpp index e18d26f2d0d..957cab143ea 100644 --- a/src/odb/src/def/defrw/defrw.cpp +++ b/src/odb/src/def/defrw/defrw.cpp @@ -27,6 +27,7 @@ // ***************************************************************************** // ***************************************************************************** +#include #include #include #include @@ -2465,9 +2466,9 @@ int cls(defrCallbackType_e c, void* cl, defiUserData ud) } break; case defrDefaultCapCbkType: - i = (long long) cl; + i = (int64_t) cl; fprintf(fout, "DEFAULTCAP %d\n", i); - numObjs = (long) i; + numObjs = (int64_t) i; break; case defrRowCbkType: row = (defiRow*) cl; @@ -3317,11 +3318,11 @@ void freeCB(void* name) } BEGIN_DEF_PARSER_NAMESPACE -extern long long nlines; +extern int64_t nlines; END_DEF_PARSER_NAMESPACE static int ccr1131444 = 0; -void lineNumberCB(long long lineNo) +void lineNumberCB(int64_t lineNo) { // The CCR 1131444 tests ability of the DEF parser to count // input line numbers out of 32-bit int range. On the first callback @@ -3359,7 +3360,7 @@ int main(int argc, char** argv) FILE* f; int res = 0; int noCalls = 0; - // long start_mem; + // int64_t start_mem; int retStr = 0; int numInFile = 0; int fileCt = 0; @@ -3374,7 +3375,7 @@ int main(int argc, char** argv) _set_output_format(_TWO_DIGIT_EXPONENT); #endif - // start_mem = (long)sbrk(0); + // start_mem = (int64_t)sbrk(0); strcpy(defaultName, "def.in"); strcpy(defaultOut, "list"); diff --git a/src/odb/src/lef/lef/lef_keywords.cpp b/src/odb/src/lef/lef/lef_keywords.cpp index eccd53da97c..921b7e9836f 100644 --- a/src/odb/src/lef/lef/lef_keywords.cpp +++ b/src/odb/src/lef/lef/lef_keywords.cpp @@ -28,6 +28,7 @@ // ***************************************************************************** #include +#include #include #include #include @@ -370,7 +371,7 @@ static inline void IncCurPos(char** curPos, char** buffer, int* bufferSize) return; } - long offset = *curPos - *buffer; + int64_t offset = *curPos - *buffer; *bufferSize *= 2; *buffer = (char*) realloc(*buffer, *bufferSize); @@ -600,6 +601,9 @@ void lefStoreAlias() int ch = lefGetc(); if (ch == EOF) { lefError(1001, "End of file in &ALIAS"); + free(aname); + free(line); + free(uc_line); return; } @@ -622,10 +626,7 @@ void lefStoreAlias() so_far += line; } - char* dup = (char*) malloc(strlen(so_far.c_str()) + 1); - - strcpy(dup, so_far.c_str()); - lefData->alias_set[strip_case(aname)] = dup; + lefData->alias_set[strip_case(aname)] = so_far; free(aname); free(line); diff --git a/src/odb/src/lef/lef/lefiLayer.cpp b/src/odb/src/lef/lef/lefiLayer.cpp index 947c250135b..9ed49156810 100644 --- a/src/odb/src/lef/lef/lefiLayer.cpp +++ b/src/odb/src/lef/lef/lefiLayer.cpp @@ -6342,6 +6342,9 @@ void lefiLayer::parseLayerEnclosure(int index) if (strcmp(value, "CUTCLASS") == 0) { // This is 58 syntax but is not in OA data model. Skip the parsing free(wrkingStr); + if (enclRule) { + free(enclRule); + } return; } if ((strcmp(value, "ABOVE") == 0) || (strcmp(value, "BELOW") == 0)) { @@ -6370,6 +6373,9 @@ void lefiLayer::parseLayerEnclosure(int index) } return; } + if (enclRule) { + free(enclRule); + } enclRule = strdup(value); value = strtok(nullptr, " "); } else if (strcmp(value, "WIDTH") == 0) { diff --git a/src/odb/src/lef/lefdiff/diffLefRW.cpp b/src/odb/src/lef/lefdiff/diffLefRW.cpp index 7b7d5bbe83b..7a00b45a1ce 100644 --- a/src/odb/src/lef/lefdiff/diffLefRW.cpp +++ b/src/odb/src/lef/lefdiff/diffLefRW.cpp @@ -30,6 +30,7 @@ // This program is the diffLef core program. It has all the callback // routines and write it out to a temporary file +#include #include #include #ifndef WIN32 @@ -67,9 +68,9 @@ void checkType(lefrCallbackType_e c) // This function will make sure it round up for all the machine double chkNum(double num) { - long tempNum; + int64_t tempNum; if ((num > 1000004) || (num < -1000004)) { - tempNum = (long) num; + tempNum = (int64_t) num; if ((tempNum % 5) == 0) { return num + 3; } diff --git a/src/odb/src/lefin/lefTechLayerCutSpacingParser.cpp b/src/odb/src/lefin/lefTechLayerCutSpacingParser.cpp index 622410d3a20..8a962e7ee51 100644 --- a/src/odb/src/lefin/lefTechLayerCutSpacingParser.cpp +++ b/src/odb/src/lefin/lefTechLayerCutSpacingParser.cpp @@ -116,14 +116,14 @@ void addAdjacentCutsSubRule( parser->curRule->setExceptSamePgnet(true); } if (className.is_initialized()) { - auto cutClassName = className.value(); + const auto& cutClassName = className.value(); auto cutClass = layer->findTechLayerCutClassRule(cutClassName.c_str()); if (cutClass != nullptr) { parser->curRule->setCutClass(cutClass); } } if (sideParallelNoPrl.is_initialized()) { - auto option = sideParallelNoPrl.value(); + const auto& option = sideParallelNoPrl.value(); if (option == "NOPRL") { parser->curRule->setNoPrl(true); } else { @@ -140,7 +140,7 @@ void addParallelOverlapSubRule(boost::optional except, parser->curRule->setType( odb::dbTechLayerCutSpacingRule::CutSpacingType::PARALLELOVERLAP); if (except.is_initialized()) { - auto exceptWhat = except.value(); + const auto& exceptWhat = except.value(); if (exceptWhat == "EXCEPTSAMENET") { parser->curRule->setExceptSameNet(true); } else if (exceptWhat == "EXCEPTSAMEMETAL") { @@ -187,7 +187,7 @@ void addSameMetalSharedEdgeSubRule( parser->curRule->setAbove(true); } if (CUTCLASS.is_initialized()) { - auto cutClassName = CUTCLASS.value(); + const auto& cutClassName = CUTCLASS.value(); auto cutClass = layer->findTechLayerCutClassRule(cutClassName.c_str()); if (cutClass != nullptr) { parser->curRule->setCutClass(cutClass); diff --git a/src/odb/src/lefout/lefout.cpp b/src/odb/src/lefout/lefout.cpp index 4737c7e457d..6dae9201c6a 100644 --- a/src/odb/src/lefout/lefout.cpp +++ b/src/odb/src/lefout/lefout.cpp @@ -24,8 +24,6 @@ namespace odb { -using boost::polygon::operators::operator+=; - int lefout::determineBloat(dbTechLayer* layer) const { int bloat = 0; @@ -56,6 +54,7 @@ void lefout::insertObstruction(dbTechLayer* layer, boost::polygon::polygon_90_set_data poly; poly = boost::polygon::rectangle_data{ rect.xMax(), rect.yMax(), rect.xMin(), rect.yMin()}; + using boost::polygon::operators::operator+=; obstructions[layer] += poly.bloat(bloat, bloat, bloat, bloat); } diff --git a/src/odb/src/swig/common/swig_common.cpp b/src/odb/src/swig/common/swig_common.cpp index cf89f1ba15f..8eac9d366ff 100644 --- a/src/odb/src/swig/common/swig_common.cpp +++ b/src/odb/src/swig/common/swig_common.cpp @@ -24,12 +24,6 @@ #include "odb/lefout.h" #include "utl/Logger.h" -using boost::polygon::operators::operator+; -using boost::polygon::operators::operator-; -using boost::polygon::operators::operator&; -using boost::polygon::operators::operator|; -using boost::polygon::operators::operator|=; - odb::dbLib* read_lef(odb::dbDatabase* db, const char* path) { utl::Logger logger(nullptr); @@ -165,6 +159,7 @@ Polygon90Set* newSetFromRect(int xLo, int yLo, int xHi, int yHi) Polygon90Set* bloatSet(const Polygon90Set* set, int bloating) { + using boost::polygon::operators::operator+; return new Polygon90Set(*set + bloating); } @@ -177,6 +172,7 @@ Polygon90Set* bloatSet(const Polygon90Set* set, int bloatX, int bloatY) Polygon90Set* shrinkSet(const Polygon90Set* set, int shrinking) { + using boost::polygon::operators::operator-; return new Polygon90Set(*set - shrinking); } @@ -189,16 +185,19 @@ Polygon90Set* shrinkSet(const Polygon90Set* set, int shrinkX, int shrinkY) Polygon90Set* andSet(const Polygon90Set* set1, const Polygon90Set* set2) { + using boost::polygon::operators::operator&; return new Polygon90Set(*set1 & *set2); } Polygon90Set* orSet(const Polygon90Set* set1, const Polygon90Set* set2) { + using boost::polygon::operators::operator|; return new Polygon90Set(*set1 | *set2); } Polygon90Set* orSets(const std::vector& sets) { + using boost::polygon::operators::operator|=; Polygon90Set* result = new Polygon90Set; for (const Polygon90Set& poly_set : sets) { *result |= poly_set; @@ -208,6 +207,7 @@ Polygon90Set* orSets(const std::vector& sets) Polygon90Set* subtractSet(const Polygon90Set* set1, const Polygon90Set* set2) { + using boost::polygon::operators::operator-; return new Polygon90Set(*set1 - *set2); } diff --git a/src/par/src/ArtNetSpec.cpp b/src/par/src/ArtNetSpec.cpp index ff00588512d..76bad345a76 100644 --- a/src/par/src/ArtNetSpec.cpp +++ b/src/par/src/ArtNetSpec.cpp @@ -374,7 +374,7 @@ bool PartitionMgr::partitionCluster( cv.push_back(resultCV[1]); for (int j = 0; j < 2; ++j) { - auto newC = resultCV[j]; + const auto& newC = resultCV[j]; int newGateNum = newC->getNumInsts(); if (newGateNum < MIN_GATE_NUM_PER_CLUSTER) { flag = false; @@ -615,7 +615,7 @@ void PartitionMgr::linCurvFit(ModuleMgr& modMgr, const double b = log(modules[n - 1]->getAvgK()); for (int i = 0; i < n; i++) { - auto m = modules[i]; + const auto& m = modules[i]; x[i] = log(m->getAvgInsts()); y[i] = log(m->getAvgT()) - b; } diff --git a/src/par/src/Multilevel.cpp b/src/par/src/Multilevel.cpp index d0c05a38275..a1d2b51c498 100644 --- a/src/par/src/Multilevel.cpp +++ b/src/par/src/Multilevel.cpp @@ -149,7 +149,7 @@ std::vector MultilevelPartitioner::SingleLevelPartition( CoarseGraphPtrs hierarchy = coarsener_->LazyFirstChoice(hgraph); // Step 2: run initial partitioning - HGraphPtr coarsest_hgraph = hierarchy.back(); + const HGraphPtr& coarsest_hgraph = hierarchy.back(); // pick top num_best_initial_solutions_ solutions from // num_initial_random_solutions_ solutions @@ -235,7 +235,7 @@ std::vector MultilevelPartitioner::SingleCycleRefinement( CoarseGraphPtrs hierarchy = coarsener_->LazyFirstChoice(hgraph); // Step 2: run initial refinement - HGraphPtr coarsest_hgraph = hierarchy.back(); + const HGraphPtr& coarsest_hgraph = hierarchy.back(); Matrix top_solutions(1); coarsest_hgraph->CopyCommunity(top_solutions[0]); int best_solution_id = 0; // only one solution diff --git a/src/par/src/Utilities.cpp b/src/par/src/Utilities.cpp index 2fd064a52cb..557df6131ce 100644 --- a/src/par/src/Utilities.cpp +++ b/src/par/src/Utilities.cpp @@ -40,7 +40,7 @@ std::string GetVectorString(const std::vector& vec) // Convert Tcl list to vector // char_match: determine if the char is part of deliminators -bool CharMatch(char c, const std::string& delim) +static bool CharMatch(char c, const std::string& delim) { auto it = delim.begin(); while (it != delim.end()) { @@ -53,9 +53,9 @@ bool CharMatch(char c, const std::string& delim) } // find the next position for deliminator char -std::string::const_iterator FindDelim(std::string::const_iterator start, - std::string::const_iterator end, - const std::string& delim) +static std::string::const_iterator FindDelim(std::string::const_iterator start, + std::string::const_iterator end, + const std::string& delim) { while (start != end && !CharMatch(*start, delim)) { start++; @@ -64,9 +64,10 @@ std::string::const_iterator FindDelim(std::string::const_iterator start, } // find the next position for non deliminator char -std::string::const_iterator FindNotDelim(std::string::const_iterator start, - std::string::const_iterator end, - const std::string& delim) +static std::string::const_iterator FindNotDelim( + std::string::const_iterator start, + std::string::const_iterator end, + const std::string& delim) { while (start != end && CharMatch(*start, delim)) { start++; diff --git a/src/pdn/src/via.h b/src/pdn/src/via.h index 32c55499ecc..f749df5458b 100644 --- a/src/pdn/src/via.h +++ b/src/pdn/src/via.h @@ -146,10 +146,22 @@ class DbBaseVia : public DbVia virtual std::string getName() const = 0; virtual odb::Rect getViaRect(bool include_enclosure, bool include_via_shape, - bool include_bottom = true, - bool include_top = true) const + bool include_bottom, + bool include_top) const = 0; + odb::Rect getViaRect(bool include_enclosure, + bool include_via_shape, + bool include_bottom) const + { + return getViaRect( + include_enclosure, include_via_shape, include_bottom, true); + } + odb::Rect getViaRect(bool include_enclosure, bool include_via_shape) const + { + return getViaRect(include_enclosure, include_via_shape, true); + } + int getCount() const { return count_; } ViaReport getViaReport() const override; @@ -187,8 +199,9 @@ class DbTechVia : public DbBaseVia std::string getName() const override; odb::Rect getViaRect(bool include_enclosure, bool include_via_shape, - bool include_bottom = true, - bool include_top = true) const override; + bool include_bottom, + bool include_top) const override; + using DbBaseVia::getViaRect; private: odb::dbTechVia* via_; @@ -243,8 +256,9 @@ class DbGenerateVia : public DbBaseVia std::string getName() const override; odb::Rect getViaRect(bool include_enclosure, bool include_via_shape, - bool include_bottom = true, - bool include_top = true) const override; + bool include_bottom, + bool include_top) const override; + using DbBaseVia::getViaRect; private: odb::Rect rect_; @@ -447,9 +461,10 @@ class ViaGenerator virtual bool isSetupValid(odb::dbTechLayer* lower, odb::dbTechLayer* upper) const; - virtual bool checkConstraints(bool check_cuts = true, - bool check_min_cut = true, - bool check_enclosure = true) const; + virtual bool checkConstraints(bool check_cuts, + bool check_min_cut, + bool check_enclosure) const; + bool checkConstraints() const { return checkConstraints(true, true, true); } // determine the shape of the vias bool build(bool bottom_is_internal_layer, bool top_is_internal_layer); diff --git a/src/ppl/src/HungarianMatching.cpp b/src/ppl/src/HungarianMatching.cpp index 5e2e1dce060..0e04fa3feef 100644 --- a/src/ppl/src/HungarianMatching.cpp +++ b/src/ppl/src/HungarianMatching.cpp @@ -93,11 +93,6 @@ void HungarianMatching::createMatrix() } } -inline bool samePos(odb::Point& a, odb::Point& b) -{ - return (a.x() == b.x() && a.y() == b.y()); -} - void HungarianMatching::getFinalAssignment(std::vector& assignment, bool assign_mirrored) { diff --git a/src/rcx/include/rcx/extPattern.h b/src/rcx/include/rcx/extPattern.h index 3137ad5912e..a4638df7f68 100644 --- a/src/rcx/include/rcx/extPattern.h +++ b/src/rcx/include/rcx/extPattern.h @@ -72,7 +72,7 @@ class extPattern int _pattern_separation; int units; - AthHash* nameHash; + AthHash* nameHash; extPattern(int wireCnt, int over1, diff --git a/src/rcx/include/rcx/util.h b/src/rcx/include/rcx/util.h index e6d63c87def..8e4fa0fc09a 100644 --- a/src/rcx/include/rcx/util.h +++ b/src/rcx/include/rcx/util.h @@ -245,7 +245,7 @@ class AthList }; // A simple hash implementation -template +template class AthHash { unsigned int* m_listOfPrimes; @@ -300,18 +300,16 @@ class AthHash const char* key; T data; }; - int _allocKeyFlag; public: AthList* m_data; unsigned int m_prime; - AthHash(unsigned int size = 100, int store = 1) + AthHash(unsigned int size = 100) { init_list_of_primes(); m_prime = l_find_largest_prime_below_number(size); m_data = new AthList[m_prime]; - _allocKeyFlag = store; } ~AthHash() @@ -321,7 +319,7 @@ class AthHash for (i = 0; i < m_prime; i++) { typename AthList::iterator iter = m_data[i].start(); while (!iter.end()) { - if (_allocKeyFlag > 0) { + if (kStoreKey) { free((void*) iter.getVal().key); } iter.next(); @@ -335,7 +333,7 @@ class AthHash unsigned int hash_val = hashFunction(key, strlen(key), m_prime); t_elem new_t_elem; new_t_elem.data = data; - if (_allocKeyFlag > 0) { + if (kStoreKey) { new_t_elem.key = strdup(key); } else { new_t_elem.key = key; diff --git a/src/rcx/src/ext.cpp b/src/rcx/src/ext.cpp index 11c39113bee..e65af855283 100644 --- a/src/rcx/src/ext.cpp +++ b/src/rcx/src/ext.cpp @@ -542,7 +542,7 @@ bool Ext::get_model_corners(const std::string& ext_model_file, Logger* logger) (int) corner_list.size(), version); for (it = corner_list.begin(); it != corner_list.end(); ++it) { - std::string str = *it; + const std::string& str = *it; // notice(0, "\t%d %s\n", cnt++, str.c_str()) fprintf(stdout, "\t%d %s\n", cnt++, str.c_str()); } diff --git a/src/rcx/src/extBenchDB.cpp b/src/rcx/src/extBenchDB.cpp index 6b8970874fe..13bec20be92 100644 --- a/src/rcx/src/extBenchDB.cpp +++ b/src/rcx/src/extBenchDB.cpp @@ -152,6 +152,7 @@ uint32_t extMain::GenExtRules(const char* rulesFileName) char* overUnderToken = strdup(p->get(1)); // M2oM1uM3 int wCnt = w->mkWords(overUnderToken, "ou"); if (wCnt < 2) { + free(overUnderToken); continue; } @@ -194,6 +195,7 @@ uint32_t extMain::GenExtRules(const char* rulesFileName) m._overUnder = false; m._over = false; } + free(overUnderToken); // TODO DIAGUNDER m._met = met; diff --git a/src/rcx/src/extModelGen.cpp b/src/rcx/src/extModelGen.cpp index ac86d7d3bea..d4ba38193a3 100644 --- a/src/rcx/src/extModelGen.cpp +++ b/src/rcx/src/extModelGen.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,7 @@ uint32_t extMain::GenExtModel(std::list spef_file_list, std::list::iterator it1; for (it1 = corner_list.begin(); it1 != corner_list.end(); ++it1) { - std::string str = *it1; + const std::string& str = *it1; corner_name.push_back(str); } uint32_t widthCnt = 12; @@ -64,7 +65,7 @@ uint32_t extMain::GenExtModel(std::list spef_file_list, uint32_t cnt = 0; std::list::iterator it; for (it = spef_file_list.begin(); it != spef_file_list.end(); ++it) { - std::string str = *it; + const std::string& str = *it; const char* filename = str.c_str(); readSPEF((char*) filename, nullptr, @@ -477,7 +478,7 @@ FILE* extModelGen::InitWriteRules(const char* name, fprintf(fp, "\nCorners %ld : ", corner_list.size()); std::list::iterator it; for (it = corner_list.begin(); it != corner_list.end(); ++it) { - std::string str = *it; + const std::string& str = *it; fprintf(fp, " %s", str.c_str()); } fprintf(fp, "\n"); @@ -589,6 +590,7 @@ uint32_t extModelGen::ReadRCDB(odb::dbBlock* block, char* overUnderToken = strdup(p->get(1)); // M2oM1uM3 int wCnt = w->mkWords(overUnderToken, "ou"); if (wCnt < 2) { + free(overUnderToken); continue; } @@ -630,6 +632,7 @@ uint32_t extModelGen::ReadRCDB(odb::dbBlock* block, m._overUnder = false; m._over = false; } + free(overUnderToken); // TODO DIAGUNDER m._met = met; diff --git a/src/rcx/src/extPatterns.cpp b/src/rcx/src/extPatterns.cpp index 253996b5ea8..2ae834ca46f 100644 --- a/src/rcx/src/extPatterns.cpp +++ b/src/rcx/src/extPatterns.cpp @@ -18,6 +18,7 @@ #include "rcx/extRCap.h" #include "rcx/extSpef.h" #include "rcx/extprocess.h" +#include "rcx/util.h" #include "utl/Logger.h" namespace rcx { @@ -244,7 +245,7 @@ extPattern::extPattern(int cnt, const int org[2], dbCreateNetUtil* net_util) { - nameHash = new AthHash(10000000, 0); // TODO: check for memory free + nameHash = new AthHash(10000000); // TODO: check for memory free patternLog = fp; opt = opt1; @@ -830,8 +831,11 @@ bool extPattern::SetPatternName() return true; } nameHash->add(pname, 1); + // pname is store in nameHash, not leaked + // NOLINTNEXTLINE(clang-analyzer-unix.Malloc) return false; } + extWirePattern* extPattern::MainPattern(float mw, float msL, float msR, @@ -1479,6 +1483,7 @@ std::vector extPattern::getMultipliers(const char* s) float v = atof(tmp); table.push_back(v); } + free(tmp); return table; } FILE* extPattern::OpenLog(int met, const char* postfix) diff --git a/src/rcx/src/extRCmodel.cpp b/src/rcx/src/extRCmodel.cpp index 04188045cf9..c5e8c521b1f 100644 --- a/src/rcx/src/extRCmodel.cpp +++ b/src/rcx/src/extRCmodel.cpp @@ -2497,7 +2497,7 @@ void extMeasure::setTargetParams(double w, _w2_nm = _w_nm; } if (s2 > 0.0 || (s2 == 0.0 && _diag)) { - long int n2 = _s2_nm = lround(1000 * s2); + int64_t n2 = _s2_nm = lround(1000 * s2); n2 = (n2 / 10) * 10; _s2_m = 0.001 * n2; diff --git a/src/rcx/src/extmain_v2.cpp b/src/rcx/src/extmain_v2.cpp index 682546ff708..66d9f7c8ea7 100644 --- a/src/rcx/src/extmain_v2.cpp +++ b/src/rcx/src/extmain_v2.cpp @@ -1005,7 +1005,7 @@ extRCModel* extMain::createCornerMap(const char* rulesFileName) = extModelGen::GetCornerNames(rulesFileName, version, logger_); std::list::iterator it; for (it = corner_list.begin(); it != corner_list.end(); ++it) { - std::string str = *it; + const std::string& str = *it; addRCCorner(str.c_str(), extCornerDbCnt, 0); _modelMap.add(extCornerDbCnt); extCornerDbCnt++; diff --git a/src/rcx/src/gs.cpp b/src/rcx/src/gs.cpp index bc6aab0d70c..2e3ab4cfc1a 100644 --- a/src/rcx/src/gs.cpp +++ b/src/rcx/src/gs.cpp @@ -13,8 +13,8 @@ namespace rcx { -static constexpr long long PIXFILL = 0xffffffffffffffffLL; -static constexpr long long PIXMAX = 0x8000000000000000LL; +static constexpr int64_t PIXFILL = 0xffffffffffffffffLL; +static constexpr int64_t PIXMAX = 0x8000000000000000LL; static constexpr int PIXADJUST = 2; /* Values for the member variable init_ @@ -457,7 +457,7 @@ bool gs::getSeqRow(const int y, int sto = stpix / PIXMAPGRID; const int str = stpix - (sto * PIXMAPGRID); - const long offset = y * plc.pixstride + sto; + const int64_t offset = y * plc.pixstride + sto; pixmap* pl = pldata_[plane].plane + offset; seqcol = GS_NONE; @@ -573,7 +573,7 @@ bool gs::getSeqCol(const int x, const int sto = x / PIXMAPGRID; const int stc = x - (sto * PIXMAPGRID); - const long offset = sto + stpix * plc.pixstride; + const int64_t offset = sto + stpix * plc.pixstride; const pixint bitmask = middle_[stc]; pixmap* pl = pldata_[plane].plane + offset; diff --git a/src/rcx/src/name.cpp b/src/rcx/src/name.cpp index b190d846a25..577e163b1fd 100644 --- a/src/rcx/src/name.cpp +++ b/src/rcx/src/name.cpp @@ -56,14 +56,19 @@ NameTable::~NameTable() NameTable::NameTable(uint32_t n, char* zero) { + bool free_zero = false; if (zero == nullptr) { zero = strdup("zeroName"); + free_zero = true; } - _hashTable = new AthHash(n, 0); + _hashTable = new AthHash(n); _bucketPool = new AthPool(0); addNewName(zero, 0); + if (free_zero) { + free(zero); + } } uint32_t NameTable::addName(const char* name, uint32_t dataId) diff --git a/src/rcx/src/name.h b/src/rcx/src/name.h index b4b2c32dbb9..9fe9266ca99 100644 --- a/src/rcx/src/name.h +++ b/src/rcx/src/name.h @@ -31,7 +31,7 @@ class NameTable uint32_t addName(const char* name, uint32_t dataId); uint32_t getDataId(int poolId); - AthHash* _hashTable; + AthHash* _hashTable; AthPool* _bucketPool; }; diff --git a/src/stt/include/stt/SteinerTreeBuilder.h b/src/stt/include/stt/SteinerTreeBuilder.h index cac933a1032..c45ba24040a 100644 --- a/src/stt/include/stt/SteinerTreeBuilder.h +++ b/src/stt/include/stt/SteinerTreeBuilder.h @@ -81,8 +81,8 @@ class SteinerTreeBuilder void setMinHPWLAlpha(int min_hpwl, float alpha); Tree flute(const std::vector& x, const std::vector& y, int acc); - int wirelength(Tree t); - void plottree(Tree t); + int wirelength(const Tree& t); + void plottree(const Tree& t); Tree flutes(const std::vector& xs, const std::vector& ys, const std::vector& s, diff --git a/src/stt/src/SteinerTreeBuilder.cpp b/src/stt/src/SteinerTreeBuilder.cpp index 6cb2893ba0a..cb73a8e9626 100644 --- a/src/stt/src/SteinerTreeBuilder.cpp +++ b/src/stt/src/SteinerTreeBuilder.cpp @@ -261,14 +261,14 @@ Tree SteinerTreeBuilder::flute(const std::vector& x, return flute_->flute(x, y, acc); } -int SteinerTreeBuilder::wirelength(Tree t) +int SteinerTreeBuilder::wirelength(const Tree& t) { - return flute_->wirelength(std::move(t)); + return flute_->wirelength(t); } -void SteinerTreeBuilder::plottree(Tree t) +void SteinerTreeBuilder::plottree(const Tree& t) { - flute_->plottree(std::move(t)); + flute_->plottree(t); } Tree SteinerTreeBuilder::flutes(const std::vector& xs, diff --git a/src/tap/src/tapcell.cpp b/src/tap/src/tapcell.cpp index d64e9434a36..c80e1e93a81 100644 --- a/src/tap/src/tapcell.cpp +++ b/src/tap/src/tapcell.cpp @@ -222,7 +222,7 @@ int Tapcell::placeTapcells(odb::dbMaster* tapcell_master, return insts; } -inline void findStartEnd(int x, +static void findStartEnd(int x, int width, const odb::dbOrientType& orient, int& x_start, diff --git a/src/utl/src/prometheus/metrics_server.cpp b/src/utl/src/prometheus/metrics_server.cpp index c3ead6960b2..44c93b9c92b 100644 --- a/src/utl/src/prometheus/metrics_server.cpp +++ b/src/utl/src/prometheus/metrics_server.cpp @@ -67,8 +67,9 @@ PrometheusMetricsServer::~PrometheusMetricsServer() boost::asio::ip::tcp::socket socket(io_context); boost::asio::ip::tcp::endpoint endpoint( boost::asio::ip::make_address("127.0.0.1"), port_); - socket.connect(endpoint); // This will unblock the accept(). - } catch (const std::exception& e) { /*Do nothing, we're dying*/ + socket.connect(endpoint); // This will unblock the accept(). + } catch (const std::exception& e) { // NOLINT(bugprone-empty-catch) + /*Do nothing, we're dying*/ } } worker_thread_.join();