Skip to content

Commit 9ca70d7

Browse files
authored
Merge pull request The-OpenROAD-Project#6899 from The-OpenROAD-Project-staging/clang-tidy
Clang tidy
2 parents f46fc4c + 703eab6 commit 9ca70d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+164
-158
lines changed

src/dpl/src/FillerPlacement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ std::pair<dbSite*, dbOrientType> Opendp::fillSite(Pixel* pixel)
141141
dbSite* selected_site = nullptr;
142142
dbOrientType selected_orient;
143143
DbuY min_height{std::numeric_limits<int>::max()};
144-
for (auto [site, orient] : pixel->sites) {
144+
for (const auto& [site, orient] : pixel->sites) {
145145
DbuY site_height{site->getHeight()};
146146
if (site_height < min_height) {
147147
min_height = site_height;

src/drt/src/db/tech/frLayer.h

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class Parser;
4646
class frLayer
4747
{
4848
public:
49+
using EnclosureConstraints = std::vector<frLef58EnclosureConstraint*>;
50+
using Width2EnclosureConstraints = std::map<frCoord, EnclosureConstraints>;
51+
using CutClass2Width2EnclosureConstraints
52+
= std::vector<Width2EnclosureConstraints>;
53+
4954
// setters
5055
void setDbLayer(odb::dbTechLayer* dbLayer) { db_layer_ = dbLayer; }
5156
void setFakeCut(bool fakeCutIn) { fakeCut_ = fakeCutIn; }
@@ -80,15 +85,18 @@ class frLayer
8085
frLayerNum getLayerNum() const { return layerNum_; }
8186
void getName(frString& nameIn) const
8287
{
83-
nameIn = (fakeCut_) ? "FR_VIA"
84-
: (fakeMasterslice_) ? "FR_MASTERSLICE"
85-
: db_layer_->getName();
88+
if (fakeCut_) {
89+
nameIn = "FR_VIA";
90+
} else {
91+
nameIn = (fakeMasterslice_) ? "FR_MASTERSLICE" : db_layer_->getName();
92+
}
8693
}
8794
frString getName() const
8895
{
89-
return (fakeCut_) ? "Fr_VIA"
90-
: (fakeMasterslice_) ? "FR_MASTERSLICE"
91-
: db_layer_->getName();
96+
if (fakeCut_) {
97+
return "Fr_VIA";
98+
}
99+
return (fakeMasterslice_) ? "FR_MASTERSLICE" : db_layer_->getName();
92100
}
93101
frUInt4 getPitch() const
94102
{
@@ -751,11 +759,9 @@ class frLayer
751759
void addLef58EnclosureConstraint(frLef58EnclosureConstraint* con)
752760
{
753761
auto addToLef58EncConstraints
754-
= [](std::vector<
755-
std::map<frCoord, std::vector<frLef58EnclosureConstraint*>>>&
756-
lef58EncConstraints,
762+
= [](CutClass2Width2EnclosureConstraints& lef58EncConstraints,
757763
frLef58EnclosureConstraint* con) {
758-
int cutClassIdx = con->getCutClassIdx();
764+
const int cutClassIdx = con->getCutClassIdx();
759765
if (lef58EncConstraints.size() <= cutClassIdx) {
760766
lef58EncConstraints.resize(cutClassIdx + 1);
761767
}
@@ -777,31 +783,39 @@ class frLayer
777783
bool above,
778784
bool eol = false) const
779785
{
780-
auto& lef58EncConstraints = above ? (eol ? aboveLef58EncEolConstraints_
781-
: aboveLef58EncConstraints_)
782-
: (eol ? belowLef58EncEolConstraints_
783-
: belowLef58EncConstraints_);
784-
if (cutClassIdx < 0 || lef58EncConstraints.size() <= cutClassIdx) {
786+
CutClass2Width2EnclosureConstraints enclosure_constraints;
787+
if (above) {
788+
enclosure_constraints
789+
= eol ? aboveLef58EncEolConstraints_ : aboveLef58EncConstraints_;
790+
} else {
791+
enclosure_constraints
792+
= eol ? belowLef58EncEolConstraints_ : belowLef58EncConstraints_;
793+
}
794+
if (cutClassIdx < 0 || enclosure_constraints.size() <= cutClassIdx) {
785795
return false;
786796
}
787-
return !lef58EncConstraints.at(cutClassIdx).empty();
797+
return !enclosure_constraints.at(cutClassIdx).empty();
788798
}
789799

790-
std::vector<frLef58EnclosureConstraint*> getLef58EnclosureConstraints(
791-
int cutClassIdx,
792-
frCoord width,
793-
bool above,
794-
bool eol = false) const
800+
frLayer::EnclosureConstraints getLef58EnclosureConstraints(int cutClassIdx,
801+
frCoord width,
802+
bool above,
803+
bool eol
804+
= false) const
795805
{
796806
// initialize with empty vector
797-
std::vector<frLef58EnclosureConstraint*> result;
807+
EnclosureConstraints result;
798808
// check class and size match first
799809
if (hasLef58EnclosureConstraint(cutClassIdx, above, eol)) {
800-
auto& lef58EncConstraints = above ? (eol ? aboveLef58EncEolConstraints_
801-
: aboveLef58EncConstraints_)
802-
: (eol ? belowLef58EncEolConstraints_
803-
: belowLef58EncConstraints_);
804-
const auto& mmap = lef58EncConstraints.at(cutClassIdx);
810+
CutClass2Width2EnclosureConstraints enclosure_constraints;
811+
if (above) {
812+
enclosure_constraints
813+
= eol ? aboveLef58EncEolConstraints_ : aboveLef58EncConstraints_;
814+
} else {
815+
enclosure_constraints
816+
= eol ? belowLef58EncEolConstraints_ : belowLef58EncConstraints_;
817+
}
818+
const auto& mmap = enclosure_constraints.at(cutClassIdx);
805819
auto it = mmap.upper_bound(width);
806820
if (it != mmap.begin()) {
807821
it--;
@@ -929,14 +943,11 @@ class frLayer
929943
std::vector<frLef58TwoWiresForbiddenSpcConstraint*>
930944
twForbiddenSpcConstraints_;
931945
std::vector<frLef58ForbiddenSpcConstraint*> forbiddenSpcConstraints_;
932-
std::vector<std::map<frCoord, std::vector<frLef58EnclosureConstraint*>>>
933-
aboveLef58EncConstraints_;
934-
std::vector<std::map<frCoord, std::vector<frLef58EnclosureConstraint*>>>
935-
belowLef58EncConstraints_;
936-
std::vector<std::map<frCoord, std::vector<frLef58EnclosureConstraint*>>>
937-
aboveLef58EncEolConstraints_;
938-
std::vector<std::map<frCoord, std::vector<frLef58EnclosureConstraint*>>>
939-
belowLef58EncEolConstraints_;
946+
947+
CutClass2Width2EnclosureConstraints aboveLef58EncConstraints_;
948+
CutClass2Width2EnclosureConstraints belowLef58EncConstraints_;
949+
CutClass2Width2EnclosureConstraints aboveLef58EncEolConstraints_;
950+
CutClass2Width2EnclosureConstraints belowLef58EncEolConstraints_;
940951
// vector of maxspacing constraints
941952
std::vector<frLef58MaxSpacingConstraint*> maxSpacingConstraints_;
942953

src/drt/src/dr/FlexDR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void FlexDRWorker::writeUpdates(const std::string& file_name)
189189
}
190190
for (const auto& marker : getDesign()->getTopBlock()->getMarkers()) {
191191
drUpdate update;
192-
update.setMarker(*(marker.get()));
192+
update.setMarker(*marker);
193193
update.setUpdateType(drUpdate::ADD_SHAPE);
194194
updates.back().push_back(update);
195195
}

src/drt/src/dr/FlexDR_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ void FlexDRWorker::route_queue_addMarkerCost(
22752275
const std::vector<std::unique_ptr<frMarker>>& markers)
22762276
{
22772277
for (auto& uMarker : markers) {
2278-
auto& marker = *(uMarker.get());
2278+
auto& marker = *uMarker;
22792279
initMazeCost_marker_route_queue(marker);
22802280
}
22812281
}

src/drt/src/dr/FlexDR_maze.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,13 +1578,15 @@ bool FlexDRWorker::mazeIterInit_sortRerouteNets(
15781578
< b->getFrNet()->getAbsPriorityLvl()) {
15791579
return false;
15801580
}
1581-
Rect boxA = a->getPinBox();
1582-
Rect boxB = b->getPinBox();
1583-
auto areaA = boxA.area();
1584-
auto areaB = boxB.area();
1585-
return (a->getNumPinsIn() == b->getNumPinsIn()
1586-
? (areaA == areaB ? a->getId() < b->getId() : areaA < areaB)
1587-
: a->getNumPinsIn() < b->getNumPinsIn());
1581+
const Rect boxA = a->getPinBox();
1582+
const Rect boxB = b->getPinBox();
1583+
const auto areaA = boxA.area();
1584+
const auto areaB = boxB.area();
1585+
const int pinsA = a->getNumPinsIn();
1586+
const int pinsB = b->getNumPinsIn();
1587+
const auto idA = a->getId();
1588+
const auto idB = b->getId();
1589+
return std::tie(pinsA, areaA, idA) < std::tie(pinsB, areaB, idB);
15881590
};
15891591
// sort
15901592
if (mazeIter == 0) {

src/drt/src/gr/FlexGRGridGraph.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ void FlexGRGridGraph::initGrids()
101101
void FlexGRGridGraph::initEdges()
102102
{
103103
for (frMIdx zIdx = 0; zIdx < (int) zCoords_.size(); zIdx++) {
104-
auto dir = is2DRouting_ ? dbTechLayerDir::NONE
105-
: (zDirs_[zIdx] ? dbTechLayerDir::HORIZONTAL
106-
: dbTechLayerDir::VERTICAL);
104+
dbTechLayerDir dir = dbTechLayerDir::NONE;
105+
if (!is2DRouting_) {
106+
dir = zDirs_[zIdx] ? dbTechLayerDir::HORIZONTAL
107+
: dbTechLayerDir::VERTICAL;
108+
}
107109
for (frMIdx xIdx = 0; xIdx < (int) xCoords_.size(); xIdx++) {
108110
for (frMIdx yIdx = 0; yIdx < (int) yCoords_.size(); yIdx++) {
109111
// horz

src/drt/src/gr/FlexGRWavefront.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include "dr/FlexMazeTypes.h"
3737
#include "frBaseTypes.h"
38+
#include "global.h"
3839

3940
namespace drt {
4041
class FlexGRWavefrontGrid

src/drt/src/io/io_parser_helper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ void io::Parser::initSecondaryVias()
292292
getViaRawPriority(viadef, priority);
293293
cuts_to_viadefs[cut_num][priority] = viadef;
294294
}
295-
for (auto [cuts, viadefs] : cuts_to_viadefs) {
296-
for (auto [priority, viadef] : viadefs) {
295+
for (const auto& [cuts, viadefs] : cuts_to_viadefs) {
296+
for (const auto& [priority, viadef] : viadefs) {
297297
if (viadef->getCutClassIdx() == default_viadef->getCutClassIdx()) {
298298
continue;
299299
}

src/gpl/src/fft.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ void FFT::doFFT()
133133
-1,
134134
binDensity_,
135135
nullptr,
136-
(int*) &workArea_[0],
137-
(float*) &csTable_[0]);
136+
workArea_.data(),
137+
csTable_.data());
138138

139139
for (int i = 0; i < binCntX_; i++) {
140140
binDensity_[i][0] *= 0.5;
@@ -191,22 +191,22 @@ void FFT::doFFT()
191191
1,
192192
electroPhi_,
193193
nullptr,
194-
(int*) &workArea_[0],
195-
(float*) &csTable_[0]);
194+
workArea_.data(),
195+
csTable_.data());
196196
ddsct2d(binCntX_,
197197
binCntY_,
198198
1,
199199
electroForceX_,
200200
nullptr,
201-
(int*) &workArea_[0],
202-
(float*) &csTable_[0]);
201+
workArea_.data(),
202+
csTable_.data());
203203
ddcst2d(binCntX_,
204204
binCntY_,
205205
1,
206206
electroForceY_,
207207
nullptr,
208-
(int*) &workArea_[0],
209-
(float*) &csTable_[0]);
208+
workArea_.data(),
209+
csTable_.data());
210210
}
211211

212212
} // namespace gpl

src/grt/src/GlobalRouter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3701,7 +3701,6 @@ void GlobalRouter::makeBtermPins(Net* net,
37013701
int posX, posY;
37023702
bterm->getFirstPinLocation(posX, posY);
37033703

3704-
std::vector<odb::dbTechLayer*> pin_layers;
37053704
std::map<odb::dbTechLayer*, std::vector<odb::Rect>> pin_boxes;
37063705

37073706
const std::string pin_name = bterm->getConstName();
@@ -3741,6 +3740,8 @@ void GlobalRouter::makeBtermPins(Net* net,
37413740
}
37423741
}
37433742

3743+
std::vector<odb::dbTechLayer*> pin_layers;
3744+
pin_layers.reserve(pin_boxes.size());
37443745
for (auto& layer_boxes : pin_boxes) {
37453746
pin_layers.push_back(layer_boxes.first);
37463747
}

0 commit comments

Comments
 (0)