Skip to content

Commit 7f7d460

Browse files
committed
fix performance-unnecessary-value-param (ignored for shared_ptr)
This check flags shared_ptr incorrectly. See https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#r34-take-a-shared_ptrwidget-parameter-to-express-shared-ownership Signed-off-by: Matt Liberty <[email protected]>
1 parent caf20b5 commit 7f7d460

32 files changed

+96
-88
lines changed

src/cut/include/cut/blif.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class Blif
4141
bool inspectBlif(const char* file_name, int& num_instances);
4242
float getRequiredTime(sta::Pin* term, bool is_rise);
4343
float getArrivalTime(sta::Pin* term, bool is_rise);
44-
void addArrival(sta::Pin* pin, std::string netName);
45-
void addRequired(sta::Pin* pin, std::string netName);
44+
void addArrival(sta::Pin* pin, const std::string& netName);
45+
void addRequired(sta::Pin* pin, const std::string& netName);
4646

4747
private:
4848
std::set<odb::dbInst*> instances_to_optimize_;

src/cut/src/blif.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,15 @@ float Blif::getArrivalTime(sta::Pin* term, bool is_rise)
613613
return arr;
614614
}
615615

616-
void Blif::addArrival(sta::Pin* pin, std::string netName)
616+
void Blif::addArrival(sta::Pin* pin, const std::string& netName)
617617
{
618618
if (arrivals_.find(netName) == arrivals_.end()) {
619619
arrivals_[netName] = std::pair<float, float>(
620620
getArrivalTime(pin, true) * 1e12, getArrivalTime(pin, false) * 1e12);
621621
}
622622
}
623623

624-
void Blif::addRequired(sta::Pin* pin, std::string netName)
624+
void Blif::addRequired(sta::Pin* pin, const std::string& netName)
625625
{
626626
if (requireds_.find(netName) == requireds_.end()) {
627627
requireds_[netName] = std::pair<float, float>(

src/cut/src/blifParser.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,43 @@ using qi::lexeme;
3838
using ascii::char_;
3939
using ascii::space;
4040

41-
void setNewInput(std::string input, cut::BlifParser* parser)
41+
void setNewInput(const std::string& input, cut::BlifParser* parser)
4242
{
4343
if (input != "\\") {
4444
parser->addInput(input);
4545
}
4646
}
4747

48-
void setNewOutput(std::string output, cut::BlifParser* parser)
48+
void setNewOutput(const std::string& output, cut::BlifParser* parser)
4949
{
5050
if (output != "\\") {
5151
parser->addOutput(output);
5252
}
5353
}
5454

55-
void setNewClock(std::string clock, cut::BlifParser* parser)
55+
void setNewClock(const std::string& clock, cut::BlifParser* parser)
5656
{
5757
if (clock != "\\") {
5858
parser->addClock(clock);
5959
}
6060
}
6161

62-
void setNewInstanceType(std::string type, cut::BlifParser* parser)
62+
void setNewInstanceType(const std::string& type, cut::BlifParser* parser)
6363
{
6464
parser->addNewInstanceType(type);
6565
}
6666

67-
void setNewGate(std::string gate, cut::BlifParser* parser)
67+
void setNewGate(const std::string& gate, cut::BlifParser* parser)
6868
{
6969
parser->addNewGate(gate);
7070
}
7171

72-
void setGateNets(std::string net, cut::BlifParser* parser)
72+
void setGateNets(const std::string& net, cut::BlifParser* parser)
7373
{
7474
parser->addConnection(net);
7575
}
7676

77-
void endParser(std::string end, cut::BlifParser* parser)
77+
void endParser(const std::string& end, cut::BlifParser* parser)
7878
{
7979
parser->endParser();
8080
}

src/drt/src/distributed/frArchive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct frOArchive : OutputArchive
2828

2929
// forward to base class
3030
template <class T>
31-
void save(T t)
31+
void save(const T& t)
3232
{
3333
OutputArchive::save(t);
3434
}

src/drt/test/fixture.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ frBlockage* Fixture::makeMacroObs(frMaster* master,
181181
}
182182

183183
frTerm* Fixture::makeMacroPin(frMaster* master,
184-
std::string name,
184+
const std::string& name,
185185
frCoord xl,
186186
frCoord yl,
187187
frCoord xh,
@@ -383,8 +383,8 @@ void Fixture::makeSpacingEndOfLineConstraint(frLayerNum layer_num,
383383

384384
frSpacingTableInfluenceConstraint* Fixture::makeSpacingTableInfluenceConstraint(
385385
frLayerNum layer_num,
386-
std::vector<frCoord> widthTbl,
387-
std::vector<std::pair<frCoord, frCoord>> valTbl)
386+
const std::vector<frCoord>& widthTbl,
387+
const std::vector<std::pair<frCoord, frCoord>>& valTbl)
388388
{
389389
frTechObject* tech = design->getTech();
390390
frLayer* layer = tech->getLayer(layer_num);
@@ -401,8 +401,8 @@ frSpacingTableInfluenceConstraint* Fixture::makeSpacingTableInfluenceConstraint(
401401
frLef58EolExtensionConstraint* Fixture::makeEolExtensionConstraint(
402402
frLayerNum layer_num,
403403
frCoord spacing,
404-
std::vector<frCoord> eol,
405-
std::vector<frCoord> ext,
404+
const std::vector<frCoord>& eol,
405+
const std::vector<frCoord>& ext,
406406
bool parallelOnly)
407407
{
408408
frTechObject* tech = design->getTech();
@@ -420,9 +420,9 @@ frLef58EolExtensionConstraint* Fixture::makeEolExtensionConstraint(
420420

421421
frSpacingTableTwConstraint* Fixture::makeSpacingTableTwConstraint(
422422
frLayerNum layer_num,
423-
std::vector<frCoord> widthTbl,
424-
std::vector<frCoord> prlTbl,
425-
std::vector<std::vector<frCoord>> spacingTbl)
423+
const std::vector<frCoord>& widthTbl,
424+
const std::vector<frCoord>& prlTbl,
425+
const std::vector<std::vector<frCoord>>& spacingTbl)
426426
{
427427
frTechObject* tech = design->getTech();
428428
frLayer* layer = tech->getLayer(layer_num);

src/drt/test/fixture.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Fixture : public ::testing::Test
8181
frCoord designRuleWidth = -1);
8282

8383
frTerm* makeMacroPin(frMaster* master,
84-
std::string name,
84+
const std::string& name,
8585
frCoord xl,
8686
frCoord yl,
8787
frCoord xh,
@@ -222,21 +222,21 @@ class Fixture : public ::testing::Test
222222

223223
frSpacingTableInfluenceConstraint* makeSpacingTableInfluenceConstraint(
224224
frLayerNum layer_num,
225-
std::vector<frCoord> widthTbl,
226-
std::vector<std::pair<frCoord, frCoord>> valTbl);
225+
const std::vector<frCoord>& widthTbl,
226+
const std::vector<std::pair<frCoord, frCoord>>& valTbl);
227227

228228
frLef58EolExtensionConstraint* makeEolExtensionConstraint(
229229
frLayerNum layer_num,
230230
frCoord spacing,
231-
std::vector<frCoord> eol,
232-
std::vector<frCoord> ext,
231+
const std::vector<frCoord>& eol,
232+
const std::vector<frCoord>& ext,
233233
bool parallelOnly = false);
234234

235235
frSpacingTableTwConstraint* makeSpacingTableTwConstraint(
236236
frLayerNum layer_num,
237-
std::vector<frCoord> widthTbl,
238-
std::vector<frCoord> prlTbl,
239-
std::vector<std::vector<frCoord>> spacingTbl);
237+
const std::vector<frCoord>& widthTbl,
238+
const std::vector<frCoord>& prlTbl,
239+
const std::vector<std::vector<frCoord>>& spacingTbl);
240240

241241
frLef58WidthTableOrthConstraint* makeWidthTblOrthConstraint(
242242
frLayerNum layer_num,

src/dst/include/dst/Distributed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Distributed
5050
{
5151
std::string ip;
5252
unsigned short port;
53-
EndPoint(std::string ip_in, unsigned short port_in)
53+
EndPoint(const std::string& ip_in, unsigned short port_in)
5454
: ip(ip_in), port(port_in)
5555
{
5656
}

src/dst/src/LoadBalancer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class LoadBalancer
5353
ip::address ip;
5454
unsigned short port;
5555
unsigned short priority;
56-
Worker(ip::address ip, unsigned short port, unsigned short priority)
56+
Worker(const ip::address& ip, unsigned short port, unsigned short priority)
5757
: ip(ip), port(port), priority(priority)
5858
{
5959
}

src/gpl/src/nesterovBase.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ void BinGrid::setRegionPoints(int lx, int ly, int ux, int uy)
607607
uy_ = uy;
608608
}
609609

610+
// NOLINTNEXTLINE(performance-unnecessary-value-param)
610611
void BinGrid::setPlacerBase(std::shared_ptr<PlacerBase> pb)
611612
{
612613
pb_ = std::move(pb);
@@ -1039,11 +1040,13 @@ NesterovPlaceVars::NesterovPlaceVars(const PlaceOptions& options)
10391040
// NesterovBaseCommon
10401041
///////////////////////////////////////////////
10411042

1042-
NesterovBaseCommon::NesterovBaseCommon(NesterovBaseVars nbVars,
1043-
std::shared_ptr<PlacerBaseCommon> pbc,
1044-
utl::Logger* log,
1045-
int num_threads,
1046-
const Clusters& clusters)
1043+
NesterovBaseCommon::NesterovBaseCommon(
1044+
NesterovBaseVars nbVars,
1045+
// NOLINTNEXTLINE(performance-unnecessary-value-param)
1046+
std::shared_ptr<PlacerBaseCommon> pbc,
1047+
utl::Logger* log,
1048+
int num_threads,
1049+
const Clusters& clusters)
10471050
: nbVars_(nbVars), num_threads_{num_threads}
10481051
{
10491052
assert(omp_get_thread_num() == 0);
@@ -1866,10 +1869,13 @@ void NesterovBaseCommon::reportInstanceExtensionByPinDensity() const
18661869
////////////////////////////////////////////////
18671870
// NesterovBase
18681871

1869-
NesterovBase::NesterovBase(NesterovBaseVars nbVars,
1870-
std::shared_ptr<PlacerBase> pb,
1871-
std::shared_ptr<NesterovBaseCommon> nbc,
1872-
utl::Logger* log)
1872+
NesterovBase::NesterovBase(
1873+
NesterovBaseVars nbVars,
1874+
// NOLINTNEXTLINE(performance-unnecessary-value-param)
1875+
std::shared_ptr<PlacerBase> pb,
1876+
// NOLINTNEXTLINE(performance-unnecessary-value-param)
1877+
std::shared_ptr<NesterovBaseCommon> nbc,
1878+
utl::Logger* log)
18731879
: nbVars_(nbVars)
18741880
{
18751881
pb_ = std::move(pb);

src/grt/src/cugr/src/geo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class BoxT
336336
{
337337
return {x_.GetNearestPointTo(pt.x()), y_.GetNearestPointTo(pt.y())};
338338
}
339-
BoxT GetNearestPointsTo(BoxT val) const
339+
BoxT GetNearestPointsTo(const BoxT& val) const
340340
{
341341
return {x_.GetNearestPointsTo(val.x_), y_.GetNearestPointsTo(val.y_)};
342342
}

0 commit comments

Comments
 (0)