Skip to content

Commit d87dbb0

Browse files
committed
cppcheck updates
1 parent 1c6f0e7 commit d87dbb0

Some content is hidden

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

63 files changed

+492
-504
lines changed

PExpr.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,11 @@ PEIdent::~PEIdent()
382382

383383
static bool find_enum_constant(LexicalScope*scope, perm_string name)
384384
{
385-
for (vector<enum_type_t*>::const_iterator cur = scope->enum_sets.begin() ;
386-
cur != scope->enum_sets.end() ; ++ cur) {
387-
for (list<named_pexpr_t>::const_iterator idx = (*cur)->names->begin() ;
388-
idx != (*cur)->names->end() ; ++ idx) {
389-
if (idx->name == name) return true;
390-
}
391-
}
385+
std::any_of(scope->enum_sets.cbegin(), scope->enum_sets.cend(),
386+
[name](const enum_type_t *cur) {
387+
return std::any_of(cur->names->cbegin(), cur->names->cend(),
388+
[name](const named_pexpr_t idx){return idx.name == name;});
389+
});
392390
return false;
393391
}
394392

PGate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class PGAssign : public PGate {
131131

132132
void dump(std::ostream&out, unsigned ind =4) const override;
133133
virtual void elaborate(Design*des, NetScope*scope) const override;
134-
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
135134

136135
private:
137136
void elaborate_unpacked_array_(Design*des, NetScope*scope, NetNet*lval) const;
@@ -170,7 +169,6 @@ class PGBuiltin : public PGate {
170169

171170
virtual void dump(std::ostream&out, unsigned ind =4) const override;
172171
virtual void elaborate(Design*, NetScope*scope) const override;
173-
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
174172

175173
private:
176174
void calculate_gate_and_lval_count_(unsigned&gate_count,

async.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ bool NetAssign::is_asynchronous()
2828
return true;
2929
}
3030

31-
bool NetCondit::is_asynchronous()
32-
{
33-
return false;
34-
}
35-
3631
/*
3732
* NetEvWait statements come from statements of the form @(...) in the
3833
* Verilog source. These event waits are considered asynchronous if

cppcheck.sup

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
// These are correct and are used to find the base (zero) pin.
2-
thisSubtraction:netlist.h:5311
3-
thisSubtraction:netlist.h:5320
2+
thisSubtraction:netlist.h:5310
3+
thisSubtraction:netlist.h:5319
44

55
// This is used when running a debugger
66
// debugger_release
77
knownConditionTrueFalse:main.cc:931
88

9+
// Yes, it's a duplicate
10+
duplicateCondition:elaborate.cc:7672
11+
12+
// To complicated to use std::find_if()
13+
useStlAlgorithm:map_named_args.cc:38
14+
915
// This are just stubs
1016
// vpi_control()
1117
unusedFunction:vpi_modules.cc:109
@@ -685,9 +691,15 @@ unusedFunction:t-dll.cc:2368
685691
// is_before()
686692
unusedFunction:verinum.cc:592
687693

688-
// Errors in the generated yacc and lex files
694+
// Errors/limitations in the generated yacc and lex files
695+
constVariablePointer:<stdout>
689696
cstyleCast:<stdout>
697+
nullPointer:<stdout>
698+
redundantInitialization:<stdout>
690699
syntaxError:<stdout>
691700
unusedFunction:<stdout>
692701
duplicateBreak:lexor.lex
702+
allocaCalled:parse.cc
693703
syntaxError:parse.cc
704+
allocaCalled:syn-rules.cc
705+
constVariablePointer:syn-rules.cc

elab_expr.cc

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ NetExpr* PEAssignPattern::elaborate_expr_packed_(Design *des, NetScope *scope,
403403
width /= dims[cur_dim].width();
404404
cur_dim++;
405405

406-
NetEConcat *concat = new NetEConcat(parms_.size(), 1, base_type);
406+
NetEConcat *neconcat = new NetEConcat(parms_.size(), 1, base_type);
407407
for (size_t idx = 0; idx < parms_.size(); idx++) {
408408
NetExpr *expr;
409409
// Handle nested assignment patterns as a special case. We do not
@@ -419,10 +419,10 @@ NetExpr* PEAssignPattern::elaborate_expr_packed_(Design *des, NetScope *scope,
419419
base_type, width,
420420
parms_[idx], need_const);
421421
if (expr)
422-
concat->set(idx, expr);
422+
neconcat->set(idx, expr);
423423
}
424424

425-
return concat;
425+
return neconcat;
426426
}
427427

428428
NetExpr* PEAssignPattern::elaborate_expr_struct_(Design *des, NetScope *scope,
@@ -439,17 +439,16 @@ NetExpr* PEAssignPattern::elaborate_expr_struct_(Design *des, NetScope *scope,
439439
des->errors++;
440440
}
441441

442-
NetEConcat *concat = new NetEConcat(parms_.size(), 1,
443-
struct_type->base_type());
442+
NetEConcat *neconcat = new NetEConcat(parms_.size(), 1, struct_type->base_type());
444443
for (size_t idx = 0; idx < std::min(parms_.size(), members.size()); idx++) {
445444
auto expr = elaborate_rval_expr(des, scope,
446445
members[idx].net_type,
447446
parms_[idx], need_const);
448447
if (expr)
449-
concat->set(idx, expr);
448+
neconcat->set(idx, expr);
450449
}
451450

452-
return concat;
451+
return neconcat;
453452
}
454453

455454
NetExpr* PEAssignPattern::elaborate_expr(Design*des, NetScope*, unsigned, unsigned) const
@@ -4263,7 +4262,7 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
42634262
else
42644263
type = sr.type;
42654264

4266-
auto path = sr.path_tail.cbegin();
4265+
auto cpath = sr.path_tail.cbegin();
42674266

42684267
ivl_assert(*this, !sr.path_head.empty());
42694268

@@ -4301,12 +4300,12 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
43014300
}
43024301
}
43034302

4304-
if (path == sr.path_tail.cend())
4303+
if (cpath == sr.path_tail.cend())
43054304
return type;
43064305

43074306
// Next look up the next path element based on name
43084307

4309-
const auto &name = path->name;
4308+
const auto &name = cpath->name;
43104309

43114310
if (auto class_type = dynamic_cast<const netclass_t*>(type)) {
43124311
// If the type is an object, the next path member may be a
@@ -4363,8 +4362,8 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
43634362
return nullptr;
43644363
}
43654364

4366-
indices = &path->index;
4367-
path++;
4365+
indices = &cpath->index;
4366+
cpath++;
43684367
}
43694368

43704369
return type;

elab_net.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,6 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
616616
// array word assignment.
617617
bool widx_flag = false;
618618

619-
list<long> unpacked_indices_const;
620-
621619
// Detect the net is a structure and there was a method path
622620
// detected. We have already broken the path_ into the path to
623621
// the net, and the path of member names. For example, if the
@@ -685,16 +683,17 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
685683
return 0;
686684
}
687685

686+
use_path.pop_front();
687+
688688
member_off += tmp_off;
689689
member_width = member->net_type->packed_width();
690690

691691
if (const netstruct_t*tmp_struct = dynamic_cast<const netstruct_t*> (member->net_type)) {
692692
struct_type = tmp_struct;
693693
} else {
694694
struct_type = 0;
695+
assert (use_path.empty());
695696
}
696-
697-
use_path.pop_front();
698697
}
699698

700699
// Look for part selects on the final member. For example if
@@ -772,6 +771,8 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
772771

773772
} else if (sig->unpacked_dimensions() > 0) {
774773

774+
list<long> unpacked_indices_const;
775+
775776
// Make sure there are enough indices to address an array element.
776777
if (path_tail.index.size() < sig->unpacked_dimensions()) {
777778
cerr << get_fileline() << ": error: Array " << path()

elab_sig.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,6 @@ bool PGate::elaborate_sig(Design*, NetScope*) const
449449
return true;
450450
}
451451

452-
bool PGBuiltin::elaborate_sig(Design*, NetScope*) const
453-
{
454-
return true;
455-
}
456-
457-
bool PGAssign::elaborate_sig(Design*, NetScope*) const
458-
{
459-
return true;
460-
}
461-
462452
bool PGModule::elaborate_sig_mod_(Design*des, NetScope*scope,
463453
const Module*rmod) const
464454
{

elaborate.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,12 +1139,9 @@ NetNet*PGModule::resize_net_to_port_(Design*des, NetScope*scope,
11391139

11401140
static bool need_bufz_for_input_port(const vector<NetNet*>&prts)
11411141
{
1142-
if (prts[0]->port_type() != NetNet::PINPUT)
1143-
return false;
1144-
1145-
if (prts[0]->pin(0).nexus()->drivers_present())
1146-
return true;
1147-
1142+
if (prts.empty()) return false;
1143+
if (prts[0]->port_type() != NetNet::PINPUT) return false;
1144+
if (prts[0]->pin(0).nexus()->drivers_present()) return true;
11481145
return false;
11491146
}
11501147

@@ -1573,7 +1570,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
15731570
// array, then there should be no sub-ports and
15741571
// the r-value expression is processed
15751572
// differently.
1576-
if (prts.size() >= 1 && prts[0]->unpacked_dimensions() > 0) {
1573+
if (!prts.empty() && prts[0]->unpacked_dimensions() > 0) {
15771574
ivl_assert(*this, prts.size()==1);
15781575
elaborate_unpacked_port(des, scope, prts[0], pins[idx],
15791576
ptype, rmod, idx);
@@ -1681,7 +1678,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
16811678
if ((sig->data_type() == IVL_VT_REAL ) &&
16821679
!prts.empty() && (prts[0]->data_type() != IVL_VT_REAL )) {
16831680
sig = cast_to_int4(des, scope, sig,
1684-
prts_vector_width/instance.size());
1681+
prts_vector_width/instance.size());
16851682
}
16861683
// If we have a bit/vector signal driving a real port
16871684
// then we convert the value to a real.
@@ -1983,7 +1980,6 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
19831980
// to the port from the outside, and the prts object is
19841981
// an array of signals to be connected to the sig.
19851982

1986-
NetConcat*ctmp;
19871983

19881984
if (prts.size() == 1) {
19891985

@@ -2027,6 +2023,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
20272023

20282024
} else switch (ptype) {
20292025
case NetNet::POUTPUT:
2026+
NetConcat*ctmp;
20302027
ctmp = new NetConcat(scope, scope->local_symbol(),
20312028
prts_vector_width, prts.size());
20322029
ctmp->set_line(*this);

libmisc/StringHeap.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
# include <cstring>
2424
# include <cassert>
2525

26-
#ifdef CHECK_WITH_VALGRIND
2726
# include "ivl_alloc.h"
27+
28+
#ifdef CHECK_WITH_VALGRIND
2829
static char **string_pool = NULL;
2930
static unsigned string_pool_count = 0;
3031
#endif
@@ -71,7 +72,7 @@ const char* StringHeap::add(const char*text)
7172
// realloc shrink of the memory region will return the
7273
// same pointer.
7374
if (rem > 0) {
74-
char*old = cell_base_;
75+
const char*old = cell_base_;
7576
cell_base_ = static_cast<char*>(realloc(cell_base_, cell_ptr_));
7677
assert(cell_base_ != 0);
7778
assert(cell_base_ == old);

netlist.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3238,7 +3238,6 @@ class NetCondit : public NetProc {
32383238
bool nested_func = false) const override;
32393239
virtual void nex_output(NexusSet&o) override;
32403240

3241-
bool is_asynchronous() override;
32423241
bool synth_async(Design*des, NetScope*scope,
32433242
NexusSet&nex_map, NetBus&nex_out,
32443243
NetBus&enables, std::vector<mask_t>&bitmasks) override;

0 commit comments

Comments
 (0)