diff --git a/src/gui/include/gui/gui.h b/src/gui/include/gui/gui.h index 6f645976ebf..c0ea4bb1e88 100644 --- a/src/gui/include/gui/gui.h +++ b/src/gui/include/gui/gui.h @@ -264,7 +264,7 @@ class Descriptor virtual std::string getName(std::any object) const = 0; virtual std::string getShortName(std::any object) const { - return getName(object); + return getName(std::move(object)); } virtual std::string getTypeName() const = 0; virtual std::string getTypeName(std::any /* object */) const diff --git a/src/gui/src/browserWidget.cpp b/src/gui/src/browserWidget.cpp index 4639421a412..c18b554f16c 100644 --- a/src/gui/src/browserWidget.cpp +++ b/src/gui/src/browserWidget.cpp @@ -345,7 +345,7 @@ void BrowserWidget::clicked(const QModelIndex& index) Selected sel = getSelectedFromIndex(index); if (sel) { - emit select({sel}); + emit select({std::move(sel)}); } } diff --git a/src/gui/src/bufferTreeDescriptor.cpp b/src/gui/src/bufferTreeDescriptor.cpp index 109fc2354b7..04ef903b89d 100644 --- a/src/gui/src/bufferTreeDescriptor.cpp +++ b/src/gui/src/bufferTreeDescriptor.cpp @@ -260,14 +260,14 @@ Descriptor::Actions BufferTreeDescriptor::getActions(std::any object) const is_focus &= focus_nets_.count(net) != 0; } if (!is_focus) { - actions.push_back(Descriptor::Action{"Focus", [this, gui, bnet]() { + actions.push_back(Descriptor::Action{"Focus", [this, gui, &bnet]() { for (auto* net : bnet.getNets()) { gui->addFocusNet(net); } return makeSelected(bnet); }}); } else { - actions.push_back(Descriptor::Action{"De-focus", [this, gui, bnet]() { + actions.push_back(Descriptor::Action{"De-focus", [this, gui, &bnet]() { for (auto* net : bnet.getNets()) { gui->removeFocusNet(net); } diff --git a/src/gui/src/clockWidget.cpp b/src/gui/src/clockWidget.cpp index ac68439e672..ac0d063964a 100644 --- a/src/gui/src/clockWidget.cpp +++ b/src/gui/src/clockWidget.cpp @@ -726,7 +726,7 @@ ClockTreeView::ClockTreeView(std::shared_ptr tree, utl::Logger* logger, QWidget* parent) : QGraphicsView(new ClockTreeScene(parent), parent), - tree_(tree), + tree_(std::move(tree)), renderer_(std::make_unique(tree_.get())), renderer_state_(RendererState::OnlyShowOnActiveWidget), scene_(nullptr), diff --git a/src/gui/src/dbDescriptors.cpp b/src/gui/src/dbDescriptors.cpp index 331fa20d41d..38e472161d3 100644 --- a/src/gui/src/dbDescriptors.cpp +++ b/src/gui/src/dbDescriptors.cpp @@ -95,7 +95,7 @@ static void populateODBProperties(Descriptor::Properties& props, if (!prefix.empty()) { prop_name = prefix + " " + prop_name; } - props.push_back({prop_name, prop_list}); + props.push_back({std::move(prop_name), prop_list}); } } @@ -217,7 +217,7 @@ static odb::dbTechLayer* getLayerSelection(odb::dbTech* tech, std::vector options; addLayersToOptions(tech, options); QStringList layers; - for (auto& [name, layer] : options) { + for (const auto& [name, layer] : options) { layers.append(QString::fromStdString(name)); } bool okay; @@ -1391,8 +1391,8 @@ void DbNetDescriptor::highlight(std::any object, Painter& painter) const auto color = painter.getPenColor(); color.a = 255; painter.setPen(color, true); - for (auto& driver : driver_locs) { - for (auto& sink : sink_locs) { + for (const auto& driver : driver_locs) { + for (const auto& sink : sink_locs) { painter.drawLine(driver, sink); } } @@ -1596,18 +1596,18 @@ bool DbNetDescriptor::getAllObjects(SelectionSet& objects) const return true; } -odb::dbNet* DbNetDescriptor::getNet(std::any object) const +odb::dbNet* DbNetDescriptor::getNet(const std::any& object) const { - odb::dbNet** net = std::any_cast(&object); + odb::dbNet* const* net = std::any_cast(&object); if (net != nullptr) { return *net; } return std::any_cast(object).net; } -odb::dbObject* DbNetDescriptor::getSink(std::any object) const +odb::dbObject* DbNetDescriptor::getSink(const std::any& object) const { - NetWithSink* net_sink = std::any_cast(&object); + const NetWithSink* net_sink = std::any_cast(&object); if (net_sink != nullptr) { return net_sink->sink; } @@ -1679,15 +1679,15 @@ Descriptor::Properties DbITermDescriptor::getProperties(std::any object) const net_value = ""; } SelectionSet aps; - for (auto& [mpin, ap_vec] : iterm->getAccessPoints()) { - for (auto ap : ap_vec) { + for (const auto& [mpin, ap_vec] : iterm->getAccessPoints()) { + for (const auto& ap : ap_vec) { DbTermAccessPoint iap{ap, iterm}; aps.insert(gui->makeSelected(iap)); } } Properties props{{"Instance", gui->makeSelected(iterm->getInst())}, {"IO type", iterm->getIoType().getString()}, - {"Net", net_value}, + {"Net", std::move(net_value)}, {"Special", iterm->isSpecial()}, {"MTerm", iterm->getMTerm()->getConstName()}, {"Access Points", aps}}; @@ -2047,7 +2047,7 @@ Descriptor::Properties DbBlockageDescriptor::getProperties( odb::Rect rect = blockage->getBBox()->getBox(); Properties props{ {"Block", gui->makeSelected(blockage->getBlock())}, - {"Instance", inst_value}, + {"Instance", std::move(inst_value)}, {"X", Property::convert_dbu(rect.xMin(), true)}, {"Y", Property::convert_dbu(rect.yMin(), true)}, {"Width", Property::convert_dbu(rect.dx(), true)}, @@ -2148,7 +2148,7 @@ bool DbObstructionDescriptor::getBBox(std::any object, odb::Rect& bbox) const void DbObstructionDescriptor::highlight(std::any object, Painter& painter) const { odb::Rect rect; - getBBox(object, rect); + getBBox(std::move(object), rect); painter.drawRect(rect); } @@ -2358,7 +2358,7 @@ Descriptor::Properties DbTechLayerDescriptor::getProperties( for (auto width : width_table->getWidthTable()) { widths.emplace_back(Property::convert_dbu(width, true)); } - props.push_back({title, widths}); + props.push_back({std::move(title), widths}); } PropertyList cutclasses; @@ -3880,9 +3880,9 @@ bool DbSiteDescriptor::getAllObjects(SelectionSet& objects) const return true; } -odb::dbSite* DbSiteDescriptor::getSite(std::any object) const +odb::dbSite* DbSiteDescriptor::getSite(const std::any& object) const { - odb::dbSite** site = std::any_cast(&object); + odb::dbSite* const* site = std::any_cast(&object); if (site != nullptr) { return *site; } @@ -3890,16 +3890,16 @@ odb::dbSite* DbSiteDescriptor::getSite(std::any object) const return ss.site; } -odb::Rect DbSiteDescriptor::getRect(std::any object) const +odb::Rect DbSiteDescriptor::getRect(const std::any& object) const { - SpecificSite* ss = std::any_cast(&object); + const SpecificSite* ss = std::any_cast(&object); if (ss != nullptr) { return ss->rect; } return odb::Rect(); } -bool DbSiteDescriptor::isSpecificSite(std::any object) const +bool DbSiteDescriptor::isSpecificSite(const std::any& object) const { return std::any_cast(&object) != nullptr; } diff --git a/src/gui/src/dbDescriptors.h b/src/gui/src/dbDescriptors.h index b33775f0622..ea98fd0ee5f 100644 --- a/src/gui/src/dbDescriptors.h +++ b/src/gui/src/dbDescriptors.h @@ -220,8 +220,8 @@ class DbNetDescriptor : public Descriptor const std::set& guide_nets_; const std::set& tracks_nets_; - odb::dbNet* getNet(std::any object) const; - odb::dbObject* getSink(std::any object) const; + odb::dbNet* getNet(const std::any& object) const; + odb::dbObject* getSink(const std::any& object) const; static const int max_iterms_ = 10000; }; @@ -660,9 +660,9 @@ class DbSiteDescriptor : public Descriptor private: odb::dbDatabase* db_; - odb::dbSite* getSite(std::any object) const; - odb::Rect getRect(std::any object) const; - bool isSpecificSite(std::any object) const; + odb::dbSite* getSite(const std::any& object) const; + odb::Rect getRect(const std::any& object) const; + bool isSpecificSite(const std::any& object) const; }; class DbRowDescriptor : public Descriptor diff --git a/src/gui/src/displayControls.cpp b/src/gui/src/displayControls.cpp index 1c43f1e425b..c084f7d9efa 100644 --- a/src/gui/src/displayControls.cpp +++ b/src/gui/src/displayControls.cpp @@ -192,7 +192,7 @@ QVariant DisplayControlModel::data(const QModelIndex& index, int role) const QString information; auto add_prop - = [props](const std::string& prop, QString& info) -> bool { + = [&props](const std::string& prop, QString& info) -> bool { auto prop_find = std::find_if( props.begin(), props.end(), [prop](const auto& p) { return p.name == prop; @@ -1067,7 +1067,7 @@ void DisplayControls::displayItemDblClicked(const QModelIndex& index) cut_color_item->setIcon(makeSwatchIcon(chosen_color)); } } - *item_color = chosen_color; + *item_color = std::move(chosen_color); if (item_pattern != nullptr) { *item_pattern = display_dialog->getSelectedPattern(); } @@ -1929,7 +1929,7 @@ void DisplayControls::techInit(odb::dbTech* tech) continue; } color.setAlpha(180); - layer_color_[layer] = color; + layer_color_[layer] = std::move(color); layer_pattern_[layer] = Qt::SolidPattern; // Default pattern is fill solid } techs_.insert(tech); diff --git a/src/gui/src/drcWidget.cpp b/src/gui/src/drcWidget.cpp index 7b21d795ea3..3cffe83f4fa 100644 --- a/src/gui/src/drcWidget.cpp +++ b/src/gui/src/drcWidget.cpp @@ -818,7 +818,7 @@ void DRCWidget::loadJSONReport(const QString& filename) shapes.emplace_back( DRCViolation::DRCLine(shape_points[2], shape_points[3])); } else if (shape_type == "polygon") { - shapes.emplace_back(DRCViolation::DRCPoly(shape_points)); + shapes.emplace_back(DRCViolation::DRCPoly(std::move(shape_points))); } else { logger_->error( utl::GUI, 58, "Unable to parse violation shape: {}", shape_type); diff --git a/src/gui/src/gui.cpp b/src/gui/src/gui.cpp index e490a53a518..c46452d372d 100644 --- a/src/gui/src/gui.cpp +++ b/src/gui/src/gui.cpp @@ -911,7 +911,7 @@ void Gui::setHeatMapSetting(const std::string& name, options.join(", ").toStdString()); } - auto current_value = settings[option]; + auto& current_value = settings[option]; if (std::holds_alternative(current_value)) { // is bool if (auto* s = std::get_if(&value)) { diff --git a/src/gui/src/heatMap.cpp b/src/gui/src/heatMap.cpp index 3ebae9770fa..a8f899d94f2 100644 --- a/src/gui/src/heatMap.cpp +++ b/src/gui/src/heatMap.cpp @@ -296,10 +296,10 @@ Renderer::Settings HeatMapDataSource::getSettings() const for (const auto& setting : settings_) { if (std::holds_alternative(setting)) { - auto set = std::get(setting); + const auto& set = std::get(setting); settings[set.name] = set.getter(); } else if (std::holds_alternative(setting)) { - auto set = std::get(setting); + const auto& set = std::get(setting); settings[set.name] = set.getter(); } } @@ -321,12 +321,12 @@ void HeatMapDataSource::setSettings(const Renderer::Settings& settings) for (const auto& setting : settings_) { if (std::holds_alternative(setting)) { - auto set = std::get(setting); + const auto& set = std::get(setting); bool temp_value = set.getter(); Renderer::setSetting(settings, set.name, temp_value); set.setter(temp_value); } else if (std::holds_alternative(setting)) { - auto set = std::get(setting); + const auto& set = std::get(setting); std::string temp_value = set.getter(); Renderer::setSetting(settings, set.name, temp_value); set.setter(temp_value); @@ -440,7 +440,7 @@ void HeatMapDataSource::setupMap() map_pt->value = 0.0; map_pt->color = default_color; - map_[x][y] = map_pt; + map_[x][y] = std::move(map_pt); } } } diff --git a/src/gui/src/heatMapSetup.cpp b/src/gui/src/heatMapSetup.cpp index 81ad8f51ce8..c23dedbbda8 100644 --- a/src/gui/src/heatMapSetup.cpp +++ b/src/gui/src/heatMapSetup.cpp @@ -373,7 +373,7 @@ void HeatMapSetup::addMultiChoiceOption( QObject::connect(combo_box, &QComboBox::currentTextChanged, - [this, option](const QString& value) { + [this, &option](const QString& value) { option.setter(value.toStdString()); destroyMap(); source_.redraw(); diff --git a/src/gui/src/inspector.cpp b/src/gui/src/inspector.cpp index da1e2d9853a..1cc050db2ea 100644 --- a/src/gui/src/inspector.cpp +++ b/src/gui/src/inspector.cpp @@ -109,7 +109,7 @@ void SelectedItemModel::updateObject() // make editor if found auto editor_found = editors.find(prop.name); if (editor_found != editors.end()) { - auto editor = (*editor_found).second; + auto& editor = (*editor_found).second; makeItemEditor(prop.name, value_item, object_, @@ -1028,7 +1028,7 @@ void Inspector::update(const Selected& object) void Inspector::handleAction(QWidget* action) { - auto callback = actions_[action]; + auto& callback = actions_[action]; Selected new_selection; try { new_selection = callback(); diff --git a/src/gui/src/mainWindow.cpp b/src/gui/src/mainWindow.cpp index a9fdb2e875d..7fcd8602ae2 100644 --- a/src/gui/src/mainWindow.cpp +++ b/src/gui/src/mainWindow.cpp @@ -1551,7 +1551,7 @@ void MainWindow::timingPathsThrough(const std::set& terms) for (const auto& term : terms) { pins.insert(settings->convertTerm(term)); } - settings->setThruPin({pins}); + settings->setThruPin({std::move(pins)}); settings->setToPin({}); timing_widget_->updatePaths(); diff --git a/src/gui/src/renderThread.cpp b/src/gui/src/renderThread.cpp index 33f0f53e106..d561de6cf1c 100644 --- a/src/gui/src/renderThread.cpp +++ b/src/gui/src/renderThread.cpp @@ -611,7 +611,8 @@ void RenderThread::drawInstanceNames(QPainter* painter, QString name = inst->getName().c_str(); auto master = inst->getMaster(); auto center = master->isBlock() || master->isPad(); - drawTextInBBox(text_color, text_font, instance_box, name, painter, center); + drawTextInBBox( + text_color, text_font, instance_box, std::move(name), painter, center); } painter->setFont(initial_font); } @@ -1404,7 +1405,7 @@ void RenderThread::drawModuleView(QPainter* painter, continue; } - const auto setting = viewer_->modules_.at(module); + const auto& setting = viewer_->modules_.at(module); if (!setting.visible) { continue; @@ -1449,7 +1450,7 @@ void RenderThread::setupIOPins(odb::dbBlock* block, const odb::Rect& bounds) QString current_text = QString::fromStdString(pin->getName()); if (font_metrics.boundingRect(current_text).width() > font_metrics.boundingRect(largest_text).width()) { - largest_text = current_text; + largest_text = std::move(current_text); } } diff --git a/src/gui/src/staGui.cpp b/src/gui/src/staGui.cpp index 85f45c93d42..4f361c7ccc9 100644 --- a/src/gui/src/staGui.cpp +++ b/src/gui/src/staGui.cpp @@ -216,9 +216,11 @@ void TimingPathsModel::sort(int col_index, Qt::SortOrder sort_order) beginResetModel(); if (sort_order == Qt::AscendingOrder) { - std::stable_sort(timing_paths_.begin(), timing_paths_.end(), sort_func); + std::stable_sort( + timing_paths_.begin(), timing_paths_.end(), std::move(sort_func)); } else { - std::stable_sort(timing_paths_.rbegin(), timing_paths_.rend(), sort_func); + std::stable_sort( + timing_paths_.rbegin(), timing_paths_.rend(), std::move(sort_func)); } endResetModel(); diff --git a/src/gui/src/staGuiInterface.cpp b/src/gui/src/staGuiInterface.cpp index bdbac269e8a..f0f49cfede0 100644 --- a/src/gui/src/staGuiInterface.cpp +++ b/src/gui/src/staGuiInterface.cpp @@ -904,7 +904,7 @@ ConeDepthMapPinSet STAGuiInterface::getFanoutCone(const sta::Pin* pin) const 0, true, // thru_disabled true); // thru_constants - return getCone(pin, pins, false); + return getCone(pin, std::move(pins), false); } ConeDepthMapPinSet STAGuiInterface::getCone(const sta::Pin* source_pin, diff --git a/src/gui/src/tclCmdHighlighter.cpp b/src/gui/src/tclCmdHighlighter.cpp index cdb76280f97..aead393377d 100644 --- a/src/gui/src/tclCmdHighlighter.cpp +++ b/src/gui/src/tclCmdHighlighter.cpp @@ -421,7 +421,7 @@ void TclCmdHighlighter::highlightBlock(const QString& text) command_data = new TclCmdUserData(); } command_data->line_continued = true; - command_data->commands = matched_commands; + command_data->commands = std::move(matched_commands); if (text.size() > 0 && text.at(text.size() - 1).toLatin1() != '\\') { command_data->line_continued = false; } diff --git a/src/gui/src/timingWidget.cpp b/src/gui/src/timingWidget.cpp index 0e9827a4daf..7ab14b6dd57 100644 --- a/src/gui/src/timingWidget.cpp +++ b/src/gui/src/timingWidget.cpp @@ -520,7 +520,7 @@ void TimingWidget::selectedRowChanged(const QItemSelection& selected_row, return; } - auto top_sel_index = sel_indices.first(); + auto& top_sel_index = sel_indices.first(); showPathDetails(top_sel_index); } @@ -532,7 +532,7 @@ void TimingWidget::selectedDetailRowChanged( if (sel_indices.isEmpty()) { return; } - auto top_sel_index = sel_indices.first(); + auto& top_sel_index = sel_indices.first(); highlightPathStage(path_details_model_, top_sel_index); } @@ -544,7 +544,7 @@ void TimingWidget::selectedCaptureRowChanged( if (sel_indices.isEmpty()) { return; } - auto top_sel_index = sel_indices.first(); + auto& top_sel_index = sel_indices.first(); highlightPathStage(capture_details_model_, top_sel_index); } @@ -558,7 +558,7 @@ void TimingWidget::copy() if (indexes.size() < 1) return; - auto sel_index = indexes.first(); + auto& sel_index = indexes.first(); if (focus_view == setup_timing_table_view_ || focus_view == hold_timing_table_view_) { auto src_index = sel_index.sibling(sel_index.row(), 5); diff --git a/src/pdn/src/PdnGen.cc b/src/pdn/src/PdnGen.cc index b9caf54646d..92e650d5b0b 100644 --- a/src/pdn/src/PdnGen.cc +++ b/src/pdn/src/PdnGen.cc @@ -1112,7 +1112,8 @@ bool PdnGen::importUPF(Grid* grid, PowerSwitchNetworkType type) const auto* pdn_switch = findSwitchedPowerCell(pswitch->getLibCell()->getName()); - const auto control_net = pswitch->getControlPorts()[0].net_name; + const auto& control_ports = pswitch->getControlPorts(); + const auto& control_net = control_ports[0].net_name; if (control_net.empty()) { logger_->error( utl::PDN, diff --git a/src/pdn/src/grid_component.cpp b/src/pdn/src/grid_component.cpp index 6b9ef9f0313..40c09b2c818 100644 --- a/src/pdn/src/grid_component.cpp +++ b/src/pdn/src/grid_component.cpp @@ -304,7 +304,7 @@ void GridComponent::cutShapes(const Shape::ObstructionTreeMap& obstructions) continue; } - replacement_shapes[shape.get()] = replacements; + replacement_shapes[shape.get()] = std::move(replacements); } for (const auto& [shape, replacement] : replacement_shapes) { diff --git a/src/pdn/src/straps.cpp b/src/pdn/src/straps.cpp index 5c01a8fe2b7..773d963aea4 100644 --- a/src/pdn/src/straps.cpp +++ b/src/pdn/src/straps.cpp @@ -669,7 +669,8 @@ std::vector PadDirectConnectionStraps::getPinsFacingCore() }; } - pins.erase(std::remove_if(pins.begin(), pins.end(), remove_func), pins.end()); + pins.erase(std::remove_if(pins.begin(), pins.end(), std::move(remove_func)), + pins.end()); if (!pins.empty()) { type_ = ConnectionType::Edge; @@ -1116,7 +1117,7 @@ void PadDirectConnectionStraps::makeShapesOverPads( ShapePtr layer_closest_shape = getClosestShape(layer_shapes, pin_shape, iterm_->getNet()); if (layer_closest_shape != nullptr) { - closest_shape = layer_closest_shape; + closest_shape = std::move(layer_closest_shape); } } if (closest_shape == nullptr) { diff --git a/src/psm/include/psm/pdnsim.h b/src/psm/include/psm/pdnsim.h index eb81ad4fcd2..e25626388a3 100644 --- a/src/psm/include/psm/pdnsim.h +++ b/src/psm/include/psm/pdnsim.h @@ -142,7 +142,7 @@ class PDNSim : public odb::dbBlockCallBackObj std::unique_ptr heatmap_; - bool debug_gui_enabled_; + bool debug_gui_enabled_ = false; GeneratedSourceSettings generated_source_settings_; diff --git a/src/psm/src/debug_gui.cpp b/src/psm/src/debug_gui.cpp index 7f1f5b3df72..1c920d064b0 100644 --- a/src/psm/src/debug_gui.cpp +++ b/src/psm/src/debug_gui.cpp @@ -91,6 +91,10 @@ gui::Descriptor::Properties NodeDescriptor::getProperties(std::any object) const auto gui = gui::Gui::get(); auto solver = getSolver(node); + if (solver == nullptr) { + return props; + } + std::vector corners; if (solver != nullptr) { corners = solver->getCorners(); @@ -296,6 +300,10 @@ gui::Descriptor::Properties ConnectionDescriptor::getProperties( auto gui = gui::Gui::get(); auto solver = getSolver(conn); + if (solver == nullptr) { + return props; + } + std::vector corners; if (solver != nullptr) { corners = solver->getCorners(); @@ -369,7 +377,8 @@ DebugGui::DebugGui(IRNetwork* network) iterm_node_color_(gui::Painter::red), bpin_node_color_(gui::Painter::blue), connection_color_(gui::Painter::yellow), - term_connection_color_(gui::Painter::red) + term_connection_color_(gui::Painter::red), + found_select_(false) { addDisplayControl(shapes_text_, true); addDisplayControl(nodes_text_, true); diff --git a/src/psm/src/debug_gui.h b/src/psm/src/debug_gui.h index 14d199d517b..5ac74b41065 100644 --- a/src/psm/src/debug_gui.h +++ b/src/psm/src/debug_gui.h @@ -214,6 +214,8 @@ class DebugGui : public gui::Renderer const gui::Painter::Color connection_color_; const gui::Painter::Color term_connection_color_; + bool found_select_; + std::map shapes_; std::map nodes_; std::map iterm_nodes_; @@ -226,7 +228,6 @@ class DebugGui : public gui::Renderer std::set selected_shapes_; std::set selected_nodes_; std::set selected_connections_; - bool found_select_; static constexpr const char* shapes_text_ = "Shapes"; static constexpr const char* nodes_text_ = "Nodes"; diff --git a/src/psm/src/pdnsim.cpp b/src/psm/src/pdnsim.cpp index 5560056b9e9..b6ef501410f 100644 --- a/src/psm/src/pdnsim.cpp +++ b/src/psm/src/pdnsim.cpp @@ -62,7 +62,6 @@ void PDNSim::init(utl::Logger* logger, sta_ = sta; resizer_ = resizer; logger_ = logger; - debug_gui_enabled_ = false; heatmap_ = std::make_unique(this, sta, logger_); heatmap_->registerHeatMap(); }