Skip to content

Commit 86b9236

Browse files
authored
Merge pull request #9115 from The-OpenROAD-Project-staging/odb-tidy
odb: clang-tidy src/db
2 parents 88a8f4c + 4c7fac3 commit 86b9236

File tree

104 files changed

+1014
-1349
lines changed

Some content is hidden

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

104 files changed

+1014
-1349
lines changed

src/odb/include/odb/db.h

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ class dbBlock : public dbObject
10341034
///
10351035
/// Get ext corner name by the index in ext Db
10361036
///
1037-
void getExtCornerName(int corner, char* cName);
1037+
std::string getExtCornerName(int corner);
10381038

10391039
///
10401040
/// Get the index in ext Db by name
@@ -6863,8 +6863,7 @@ class dbViaParams : private _dbViaParams
68636863
{
68646864
public:
68656865
dbViaParams();
6866-
dbViaParams(const dbViaParams& p);
6867-
~dbViaParams();
6866+
dbViaParams(const dbViaParams& p) = default;
68686867

68696868
int getXCutSize() const;
68706869
int getYCutSize() const;
@@ -10141,48 +10140,55 @@ class dbTechLayerCutSpacingTableDefRule : public dbObject
1014110140
bool isOppositeEnclosureResizeSpacingValid() const;
1014210141

1014310142
// User Code Begin dbTechLayerCutSpacingTableDefRule
10144-
void addPrlForAlignedCutEntry(std::string from, std::string to);
10143+
void addPrlForAlignedCutEntry(const std::string& from, const std::string& to);
1014510144

10146-
void addCenterToCenterEntry(std::string from, std::string to);
10145+
void addCenterToCenterEntry(const std::string& from, const std::string& to);
1014710146

10148-
void addCenterAndEdgeEntry(std::string from, std::string to);
10147+
void addCenterAndEdgeEntry(const std::string& from, const std::string& to);
1014910148

10150-
void addPrlEntry(std::string from, std::string to, int ccPrl);
10149+
void addPrlEntry(const std::string& from, const std::string& to, int ccPrl);
1015110150

10152-
void addEndExtensionEntry(std::string cls, int ext);
10151+
void addEndExtensionEntry(const std::string& cls, int ext);
1015310152

10154-
void addSideExtensionEntry(std::string cls, int ext);
10153+
void addSideExtensionEntry(const std::string& cls, int ext);
1015510154

10156-
void addExactElignedEntry(std::string cls, int spacing);
10155+
void addExactElignedEntry(const std::string& cls, int spacing);
1015710156

10158-
void addNonOppEncSpacingEntry(std::string cls, int spacing);
10157+
void addNonOppEncSpacingEntry(const std::string& cls, int spacing);
1015910158

10160-
void addOppEncSpacingEntry(std::string cls, int rsz1, int rsz2, int spacing);
10159+
void addOppEncSpacingEntry(const std::string& cls,
10160+
int rsz1,
10161+
int rsz2,
10162+
int spacing);
1016110163

1016210164
dbTechLayer* getSecondLayer() const;
1016310165

10164-
bool isCenterToCenter(std::string cutClass1, std::string cutClass2);
10166+
bool isCenterToCenter(const std::string& cutClass1,
10167+
const std::string& cutClass2);
1016510168

10166-
bool isCenterAndEdge(std::string cutClass1, std::string cutClass2);
10169+
bool isCenterAndEdge(const std::string& cutClass1,
10170+
const std::string& cutClass2);
1016710171

10168-
bool isPrlForAlignedCutClasses(std::string cutClass1, std::string cutClass2);
10172+
bool isPrlForAlignedCutClasses(const std::string& cutClass1,
10173+
const std::string& cutClass2);
1016910174

1017010175
int getPrlEntry(const std::string& cutClass1, const std::string& cutClass2);
1017110176

10172-
void setSpacingTable(std::vector<std::vector<std::pair<int, int>>> table,
10173-
std::map<std::string, uint> row_map,
10174-
std::map<std::string, uint> col_map);
10177+
void setSpacingTable(
10178+
const std::vector<std::vector<std::pair<int, int>>>& table,
10179+
const std::map<std::string, uint>& row_map,
10180+
const std::map<std::string, uint>& col_map);
1017510181

1017610182
void getSpacingTable(std::vector<std::vector<std::pair<int, int>>>& table,
1017710183
std::map<std::string, uint>& row_map,
1017810184
std::map<std::string, uint>& col_map);
1017910185

1018010186
int getMaxSpacing(std::string cutClass, bool SIDE) const;
1018110187

10182-
int getExactAlignedSpacing(std::string cutClass) const;
10188+
int getExactAlignedSpacing(const std::string& cutClass) const;
1018310189

10184-
int getMaxSpacing(std::string cutClass1,
10185-
std::string cutClass2,
10190+
int getMaxSpacing(const std::string& cutClass1,
10191+
const std::string& cutClass2,
1018610192
LOOKUP_STRATEGY strategy = MAX) const;
1018710193

1018810194
int getSpacing(std::string class1,
@@ -10208,7 +10214,7 @@ class dbTechLayerCutSpacingTableOrthRule : public dbObject
1020810214
void getSpacingTable(std::vector<std::pair<int, int>>& tbl) const;
1020910215

1021010216
// User Code Begin dbTechLayerCutSpacingTableOrthRule
10211-
void setSpacingTable(std::vector<std::pair<int, int>> tbl);
10217+
void setSpacingTable(const std::vector<std::pair<int, int>>& tbl);
1021210218

1021310219
static dbTechLayerCutSpacingTableOrthRule* create(dbTechLayer* parent);
1021410220

@@ -10503,7 +10509,7 @@ class dbTechLayerMinCutRule : public dbObject
1050310509

1050410510
// User Code Begin dbTechLayerMinCutRule
1050510511

10506-
void setCutsPerCutClass(std::string cut_class, int num_cuts);
10512+
void setCutsPerCutClass(const std::string& cut_class, int num_cuts);
1050710513

1050810514
static dbTechLayerMinCutRule* create(dbTechLayer* layer);
1050910515

@@ -10930,17 +10936,17 @@ class dbTechLayerSpacingTablePrlRule : public dbObject
1093010936

1093110937
static void destroy(dbTechLayerSpacingTablePrlRule* rule);
1093210938

10933-
void setTable(std::vector<int> width_tbl,
10934-
std::vector<int> length_tbl,
10935-
std::vector<std::vector<int>> spacing_tbl,
10936-
std::map<uint, std::pair<int, int>> excluded_map);
10939+
void setTable(const std::vector<int>& width_tbl,
10940+
const std::vector<int>& length_tbl,
10941+
const std::vector<std::vector<int>>& spacing_tbl,
10942+
const std::map<uint, std::pair<int, int>>& excluded_map);
1093710943
void getTable(std::vector<int>& width_tbl,
1093810944
std::vector<int>& length_tbl,
1093910945
std::vector<std::vector<int>>& spacing_tbl,
1094010946
std::map<uint, std::pair<int, int>>& excluded_map);
1094110947

1094210948
void setSpacingTableInfluence(
10943-
std::vector<std::tuple<int, int, int>> influence_tbl);
10949+
const std::vector<std::tuple<int, int, int>>& influence_tbl);
1094410950

1094510951
int getSpacing(int width, int length) const;
1094610952

src/odb/include/odb/dbShape.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ class dbWireShapeItr
251251
{
252252
public:
253253
dbWireShapeItr();
254-
~dbWireShapeItr();
255254

256255
void begin(dbWire* wire);
257256
bool next(dbShape& shape);
@@ -311,7 +310,6 @@ class dbWirePathItr
311310
{
312311
public:
313312
dbWirePathItr();
314-
~dbWirePathItr();
315313

316314
void begin(dbWire* wire);
317315
bool getNextPath(dbWirePath& path);
@@ -352,6 +350,16 @@ class dbInstShapeItr
352350
bool next(dbShape& shape);
353351

354352
private:
353+
enum State
354+
{
355+
kInit = 0,
356+
kMtermItr = 1,
357+
kMpinItr = 2,
358+
kMboxItr = 3,
359+
kObsItr = 4,
360+
kViaBoxItr = 5,
361+
kPinsDone = 6
362+
};
355363
void getShape(dbBox* box, dbShape& shape);
356364
void getViaBox(dbBox* box, dbShape& shape);
357365

@@ -361,7 +369,7 @@ class dbInstShapeItr
361369
dbSet<dbBox>::iterator box_itr_;
362370
dbSet<dbMTerm>::iterator mterm_itr_;
363371
dbSet<dbMPin>::iterator mpin_itr_;
364-
int state_;
372+
State state_;
365373
dbInst* inst_;
366374
dbMaster* master_;
367375
dbMPin* _mpin_;
@@ -372,7 +380,7 @@ class dbInstShapeItr
372380
dbSet<dbBox>::iterator via_box_itr_;
373381
Point via_pt_;
374382
bool expand_vias_;
375-
int prev_state_;
383+
State prev_state_;
376384
};
377385

378386
///////////////////////////////////////////////////////////////////////////////
@@ -388,6 +396,14 @@ class dbITermShapeItr
388396
bool next(dbShape& shape);
389397

390398
private:
399+
enum State
400+
{
401+
kInit,
402+
kMpinItr,
403+
kMboxItr,
404+
kViaBoxItr
405+
};
406+
391407
void getShape(dbBox* box, dbShape& shape);
392408
void getViaBox(dbBox* box, dbShape& shape);
393409

@@ -396,7 +412,7 @@ class dbITermShapeItr
396412
dbMTerm* mterm_;
397413
dbSet<dbBox>::iterator box_itr_;
398414
dbSet<dbMPin>::iterator mpin_itr_;
399-
int state_;
415+
State state_;
400416
dbITerm* iterm_;
401417
dbMPin* mpin_;
402418
dbTransform transform_;
@@ -495,7 +511,7 @@ class dbHierInstShapeItr
495511
bool draw_vias,
496512
bool draw_segments);
497513
bool iterate_leaf(dbInst* inst, unsigned filter, int level);
498-
void push_transform(dbTransform t);
514+
void push_transform(const dbTransform& t);
499515
void transform(dbShape& shape);
500516

501517
std::vector<dbTransform> transforms_;

src/odb/include/odb/dbViaParams.h

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,30 @@ class dbOStream;
1616
class _dbViaParams
1717
{
1818
public:
19-
_dbViaParams(const _dbViaParams& v);
20-
_dbViaParams();
21-
~_dbViaParams();
19+
_dbViaParams(const _dbViaParams& v) = default;
20+
_dbViaParams() = default;
2221

2322
bool operator==(const _dbViaParams& rhs) const;
2423
bool operator!=(const _dbViaParams& rhs) const { return !operator==(rhs); }
2524
friend dbOStream& operator<<(dbOStream& stream, const _dbViaParams& v);
2625
friend dbIStream& operator>>(dbIStream& stream, _dbViaParams& v);
2726

28-
int x_cut_size_;
29-
int y_cut_size_;
30-
int x_cut_spacing_;
31-
int y_cut_spacing_;
32-
int x_top_enclosure_;
33-
int y_top_enclosure_;
34-
int x_bot_enclosure_;
35-
int y_bot_enclosure_;
36-
int num_cut_rows_;
37-
int num_cut_cols_;
38-
int x_origin_;
39-
int y_origin_;
40-
int x_top_offset_;
41-
int y_top_offset_;
42-
int x_bot_offset_;
43-
int y_bot_offset_;
27+
int x_cut_size_{0};
28+
int y_cut_size_{0};
29+
int x_cut_spacing_{0};
30+
int y_cut_spacing_{0};
31+
int x_top_enclosure_{0};
32+
int y_top_enclosure_{0};
33+
int x_bot_enclosure_{0};
34+
int y_bot_enclosure_{0};
35+
int num_cut_rows_{1};
36+
int num_cut_cols_{1};
37+
int x_origin_{0};
38+
int y_origin_{0};
39+
int x_top_offset_{0};
40+
int y_top_offset_{0};
41+
int x_bot_offset_{0};
42+
int y_bot_offset_{0};
4443
dbId<_dbTechLayer> top_layer_;
4544
dbId<_dbTechLayer> cut_layer_;
4645
dbId<_dbTechLayer> bot_layer_;

src/odb/include/odb/dbWireCodec.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ class dbWireEncoder
180180
///
181181
dbWireEncoder();
182182

183-
///
184-
/// dbWireEncoder destructor:
185-
///
186-
~dbWireEncoder();
187-
188183
///
189184
/// Begin a new encoding.
190185
///
@@ -515,11 +510,6 @@ class dbWireDecoder
515510
///
516511
dbWireDecoder();
517512

518-
///
519-
/// Destroy a decoder.
520-
///
521-
~dbWireDecoder();
522-
523513
///
524514
/// Begin decoding a wire.
525515
///

src/odb/include/odb/dbWireGraph.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ class dbWireGraph
249249
friend class dbWireGraph;
250250
};
251251

252-
dbWireGraph();
253-
~dbWireGraph();
252+
dbWireGraph() = default;
254253

255254
// Clear this graph.
256255
void clear();

src/odb/src/codeGenerator/schema/chip/dbProperty.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"fields": [
77
{
88
"name": "type",
9-
"type": "uint",
9+
"type": "PropTypeEnum",
1010
"bits": 4,
1111
"flags": ["private"]
1212
},

src/odb/src/codeGenerator/templates/impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace odb {
106106
{% if 'flags' not in _struct
107107
or ('no-serializer' not in _struct['flags']
108108
and 'no-serializer-in' not in _struct['flags']) %}
109-
{{- si.serializer_in(_struct, klass, _struct.name)}}
109+
{{- si.serializer_in(_struct, klass, _struct.name, static=True)}}
110110
{% endif %}
111111
{% endfor %}
112112
{{- si.serializer_in(klass)}}
@@ -116,7 +116,7 @@ namespace odb {
116116
{% if 'flags' not in _struct
117117
or ('no-serializer' not in _struct['flags']
118118
and 'no-serializer-out' not in _struct['flags']) %}
119-
{{- so.serializer_out(_struct, klass, _struct.name)}}
119+
{{- so.serializer_out(_struct, klass, _struct.name, static=True)}}
120120
{% endif %}
121121
{% endfor %}
122122
{{- so.serializer_out(klass)}}

src/odb/src/codeGenerator/templates/impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ namespace odb {
2828
//User Code Begin Classes
2929
//User Code End Classes
3030

31+
//User Code Begin Types
32+
//User Code End Types
33+
3134
{{ macros.make_structs(klass, is_public=False) }}
3235
// User Code Begin Structs
3336
// User Code End Structs

src/odb/src/codeGenerator/templates/serializer_in.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{% macro serializer_in(klass, parent=None, comment_tag = "") %}
1+
{% macro serializer_in(klass, parent=None, comment_tag = "", static=False) %}
22
{% set sname = (parent.name + "::" if parent else '_') + klass.name %}
3+
{% if static %}static{% endif %}
34
dbIStream& operator>>(dbIStream& stream, {{sname}}& obj)
45
{
56
{% for field in klass.fields %}

src/odb/src/codeGenerator/templates/serializer_out.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
{% macro serializer_out(klass, parent=None, comment_tag = "") %}
1+
{% macro serializer_out(klass, parent=None, comment_tag = "", static=False) %}
22
{% set sname = (parent.name + "::" if parent else '_') + klass.name %}
3+
{% if static %}static{% endif %}
34
dbOStream& operator<<(dbOStream& stream, const {{sname}}& obj)
45
{
56
{% if klass.ostream_scope %}

0 commit comments

Comments
 (0)