diff --git a/AStatement.h b/AStatement.h index f5815af4c..973b76f41 100644 --- a/AStatement.h +++ b/AStatement.h @@ -1,7 +1,7 @@ #ifndef IVL_AStatement_H #define IVL_AStatement_H /* - * Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -40,10 +40,10 @@ class AContrib : public Statement { public: AContrib(PExpr*lval, PExpr*rval); - ~AContrib(); + ~AContrib() override; - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; private: PExpr*lval_; @@ -61,7 +61,7 @@ class AProcess : public LineInfo { AProcess(ivl_process_type_t t, Statement*st) : type_(t), statement_(st) { } - ~AProcess(); + ~AProcess() override; bool elaborate(Design*des, NetScope*scope) const; diff --git a/Makefile.in b/Makefile.in index f13a5615e..377ecb34a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -184,6 +184,8 @@ endif cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/cppcheck-global.sup \ --suppressions-list=$(srcdir)/cppcheck.sup \ -UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \ -UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \ diff --git a/Module.h b/Module.h index 3b77fb8c8..eecfbe781 100644 --- a/Module.h +++ b/Module.h @@ -1,7 +1,7 @@ #ifndef IVL_Module_H #define IVL_Module_H /* - * Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -74,7 +74,7 @@ class Module : public PScopeExtra, public PNamedItem { /* The name passed here is the module name, not the instance name. This name must be a permallocated string. */ explicit Module(LexicalScope*parent, perm_string name); - ~Module(); + ~Module() override; /* Initially false. This is set to true if the module has been declared as a library module. This makes the module @@ -167,7 +167,7 @@ class Module : public PScopeExtra, public PNamedItem { bool elaborate_sig(Design*, NetScope*scope) const; - SymbolType symbol_type() const; + SymbolType symbol_type() const override; bool can_be_toplevel() const; diff --git a/PExpr.h b/PExpr.h index 116490c50..f91025e70 100644 --- a/PExpr.h +++ b/PExpr.h @@ -60,7 +60,7 @@ class PExpr : public LineInfo { static const char*width_mode_name(width_mode_t mode); PExpr(); - virtual ~PExpr(); + virtual ~PExpr() override; virtual void dump(std::ostream&) const; @@ -204,17 +204,17 @@ class PEAssignPattern : public PExpr { public: explicit PEAssignPattern(); explicit PEAssignPattern(const std::list&p); - ~PEAssignPattern(); + ~PEAssignPattern() override; - void dump(std::ostream&) const; + void dump(std::ostream&) const override; - virtual unsigned test_width(Design*des, NetScope*scope, width_mode_t&mode); + virtual unsigned test_width(Design*des, NetScope*scope, width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; private: NetExpr* elaborate_expr_packed_(Design *des, NetScope *scope, ivl_variable_type_t base_type, @@ -242,35 +242,35 @@ class PEConcat : public PExpr { public: explicit PEConcat(const std::list&p, PExpr*r =0); - ~PEConcat(); + ~PEConcat() override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; - virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type); + virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetNet* elaborate_lnet(Design*des, NetScope*scope, - bool var_allowed_in_sv) const; + bool var_allowed_in_sv) const override; virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope, - bool var_allowed_in_sv) const; + bool var_allowed_in_sv) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; virtual NetAssign_* elaborate_lval(Design*des, NetScope*scope, bool is_cassign, bool is_force, - bool is_init = false) const; + bool is_init = false) const override; virtual bool is_collapsible_net(Design*des, NetScope*scope, - NetNet::PortType port_type) const; + NetNet::PortType port_type) const override; private: NetNet* elaborate_lnet_common_(Design*des, NetScope*scope, bool bidirectional_flag, @@ -299,14 +299,14 @@ class PEEvent : public PExpr { // Use this constructor to create events based on edges or levels. PEEvent(edge_t t, PExpr*e); - ~PEEvent(); + ~PEEvent() override; edge_t type() const; PExpr* expr() const; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; private: edge_t type_; @@ -320,19 +320,19 @@ class PEFNumber : public PExpr { public: explicit PEFNumber(verireal*vp); - ~PEFNumber(); + ~PEFNumber() override; const verireal& value() const; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; private: verireal*value_; @@ -344,38 +344,38 @@ class PEIdent : public PExpr { explicit PEIdent(perm_string, unsigned lexical_pos, bool no_implicit_sig=false); explicit PEIdent(PPackage*pkg, const pform_name_t&name, unsigned lexical_pos); explicit PEIdent(const pform_name_t&, unsigned lexical_pos); - ~PEIdent(); + ~PEIdent() override; // Add another name to the string of hierarchy that is the // current identifier. void append_name(perm_string); - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; - virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type); + virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; // Identifiers are allowed (with restrictions) is assign l-values. - virtual NetNet* elaborate_lnet(Design*des, NetScope*scope, bool var_allowed_in_sv) const; + virtual NetNet* elaborate_lnet(Design*des, NetScope*scope, bool var_allowed_in_sv) const override; - virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope, bool var_allowed_in_sv) const; + virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope, bool var_allowed_in_sv) const override; // Identifiers are also allowed as procedural assignment l-values. virtual NetAssign_* elaborate_lval(Design*des, NetScope*scope, bool is_cassign, bool is_force, - bool is_init = false) const; + bool is_init = false) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; // Elaborate the PEIdent as a port to a module. This method // only applies to Ident expressions. @@ -387,7 +387,7 @@ class PEIdent : public PExpr { NetNet* elaborate_unpacked_net(Design*des, NetScope*sc) const; virtual bool is_collapsible_net(Design*des, NetScope*scope, - NetNet::PortType port_type) const; + NetNet::PortType port_type) const override; const pform_scoped_name_t& path() const { return path_; } @@ -562,16 +562,16 @@ class PENewArray : public PExpr { public: explicit PENewArray (PExpr*s, PExpr*i); - ~PENewArray(); + ~PENewArray() override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; private: PExpr*size_; @@ -587,18 +587,18 @@ class PENewClass : public PExpr { explicit PENewClass (const std::list &p, data_type_t *class_type = nullptr); - ~PENewClass(); + ~PENewClass() override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; // Class objects don't have a useful width, but the expression // is IVL_VT_CLASS. virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; // Note that class (new) expressions only appear in context // that uses this form of the elaborate_expr method. In fact, // the type argument is going to be a netclass_t object. virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; private: NetExpr* elaborate_expr_constructor_(Design*des, NetScope*scope, @@ -613,18 +613,18 @@ class PENewClass : public PExpr { class PENewCopy : public PExpr { public: explicit PENewCopy(PExpr*src); - ~PENewCopy(); + ~PENewCopy() override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; // Class objects don't have a useful width, but the expression // is IVL_VT_CLASS. virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; // Note that class (new) expressions only appear in context // that uses this form of the elaborate_expr method. In fact, // the type argument is going to be a netclass_t object. virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; private: PExpr*src_; @@ -633,39 +633,39 @@ class PENewCopy : public PExpr { class PENull : public PExpr { public: explicit PENull(); - ~PENull(); + ~PENull() override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; }; class PENumber : public PExpr { public: explicit PENumber(verinum*vp); - ~PENumber(); + ~PENumber() override; const verinum& value() const; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr *elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetEConst*elaborate_expr(Design*des, NetScope*, - unsigned expr_wid, unsigned) const; + unsigned expr_wid, unsigned) const override; virtual NetAssign_* elaborate_lval(Design*des, NetScope*scope, bool is_cassign, bool is_force, - bool is_init = false) const; + bool is_init = false) const override; private: verinum*const value_; @@ -682,19 +682,19 @@ class PEString : public PExpr { public: explicit PEString(char*s); - ~PEString(); + ~PEString() override; std::string value() const; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetEConst*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetEConst*elaborate_expr(Design*des, NetScope*, - unsigned expr_wid, unsigned) const; + unsigned expr_wid, unsigned) const override; private: char*text_; @@ -703,13 +703,13 @@ class PEString : public PExpr { class PETypename : public PExpr { public: explicit PETypename(data_type_t*data_type); - ~PETypename(); + ~PETypename() override; - virtual void dump(std::ostream&) const; + virtual void dump(std::ostream&) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; inline data_type_t* get_type() const { return data_type_; } @@ -721,20 +721,20 @@ class PEUnary : public PExpr { public: explicit PEUnary(char op, PExpr*ex); - ~PEUnary(); + ~PEUnary() override; - virtual void dump(std::ostream&out) const; + virtual void dump(std::ostream&out) const override; - virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type); + virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; public: inline char get_op() const { return op_; } @@ -752,20 +752,20 @@ class PEBinary : public PExpr { public: explicit PEBinary(char op, PExpr*l, PExpr*r); - ~PEBinary(); + ~PEBinary() override; - virtual void dump(std::ostream&out) const; + virtual void dump(std::ostream&out) const override; - virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type); + virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; protected: char op_; @@ -796,13 +796,13 @@ class PEBComp : public PEBinary { public: explicit PEBComp(char op, PExpr*l, PExpr*r); - ~PEBComp(); + ~PEBComp() override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; NetExpr* elaborate_expr(Design*des, NetScope*scope, - unsigned expr_wid, unsigned flags) const; + unsigned expr_wid, unsigned flags) const override; private: unsigned l_width_; @@ -816,13 +816,13 @@ class PEBLogic : public PEBinary { public: explicit PEBLogic(char op, PExpr*l, PExpr*r); - ~PEBLogic(); + ~PEBLogic() override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; NetExpr* elaborate_expr(Design*des, NetScope*scope, - unsigned expr_wid, unsigned flags) const; + unsigned expr_wid, unsigned flags) const override; }; /* @@ -834,38 +834,38 @@ class PEBLeftWidth : public PEBinary { public: explicit PEBLeftWidth(char op, PExpr*l, PExpr*r); - ~PEBLeftWidth() =0; + ~PEBLeftWidth() override =0; virtual NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp, unsigned expr_wid) const =0; protected: virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; }; class PEBPower : public PEBLeftWidth { public: explicit PEBPower(char op, PExpr*l, PExpr*r); - ~PEBPower(); + ~PEBPower() override; NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp, - unsigned expr_wid) const; + unsigned expr_wid) const override; }; class PEBShift : public PEBLeftWidth { public: explicit PEBShift(char op, PExpr*l, PExpr*r); - ~PEBShift(); + ~PEBShift() override; NetExpr*elaborate_expr_leaf(Design*des, NetExpr*lp, NetExpr*rp, - unsigned expr_wid) const; + unsigned expr_wid) const override; }; /* @@ -876,20 +876,20 @@ class PETernary : public PExpr { public: explicit PETernary(PExpr*e, PExpr*t, PExpr*f); - ~PETernary(); + ~PETernary() override; - virtual void dump(std::ostream&out) const; + virtual void dump(std::ostream&out) const override; - virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type); + virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; virtual NetExpr*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; private: NetExpr* elab_and_eval_alternative_(Design*des, NetScope*scope, @@ -924,22 +924,22 @@ class PECallFunction : public PExpr { explicit PECallFunction(const pform_name_t &n, const std::list &parms); explicit PECallFunction(perm_string n, const std::list &parms); - ~PECallFunction(); + ~PECallFunction() override; - virtual void dump(std::ostream &) const; + virtual void dump(std::ostream &) const override; - virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type); + virtual void declare_implicit_nets(LexicalScope*scope, NetNet::Type type) override; - virtual bool has_aa_term(Design*des, NetScope*scope) const; + virtual bool has_aa_term(Design*des, NetScope*scope) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - unsigned expr_wid, unsigned flags) const; + unsigned expr_wid, unsigned flags) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; private: pform_scoped_name_t path_; @@ -991,18 +991,18 @@ class PECastSize : public PExpr { public: explicit PECastSize(PExpr*size, PExpr*base); - ~PECastSize(); + ~PECastSize() override; - void dump(std::ostream &out) const; + void dump(std::ostream &out) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; - virtual bool has_aa_term(Design *des, NetScope *scope) const; + virtual bool has_aa_term(Design *des, NetScope *scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; private: PExpr* size_; @@ -1016,20 +1016,20 @@ class PECastType : public PExpr { public: explicit PECastType(data_type_t*target, PExpr*base); - ~PECastType(); + ~PECastType() override; - void dump(std::ostream &out) const; + void dump(std::ostream &out) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - ivl_type_t type, unsigned flags) const; + ivl_type_t type, unsigned flags) const override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, - unsigned expr_wid, unsigned flags) const; + unsigned expr_wid, unsigned flags) const override; - virtual bool has_aa_term(Design *des, NetScope *scope) const; + virtual bool has_aa_term(Design *des, NetScope *scope) const override; virtual unsigned test_width(Design*des, NetScope*scope, - width_mode_t&mode); + width_mode_t&mode) override; private: data_type_t* target_; @@ -1044,16 +1044,16 @@ class PECastSign : public PExpr { public: explicit PECastSign(bool signed_flag, PExpr *base); - ~PECastSign() = default; + ~PECastSign() override = default; - void dump(std::ostream &out) const; + void dump(std::ostream &out) const override; NetExpr* elaborate_expr(Design *des, NetScope *scope, - unsigned expr_wid, unsigned flags) const; + unsigned expr_wid, unsigned flags) const override; - virtual bool has_aa_term(Design *des, NetScope *scope) const; + virtual bool has_aa_term(Design *des, NetScope *scope) const override; - unsigned test_width(Design *des, NetScope *scope, width_mode_t &mode); + unsigned test_width(Design *des, NetScope *scope, width_mode_t &mode) override; private: std::unique_ptr base_; @@ -1067,11 +1067,11 @@ class PEVoid : public PExpr { public: explicit PEVoid(); - ~PEVoid(); + ~PEVoid() override; virtual NetExpr*elaborate_expr(Design*des, NetScope*scope, unsigned expr_wid, - unsigned flags) const; + unsigned flags) const override; }; #endif /* IVL_PExpr_H */ diff --git a/PGate.h b/PGate.h index 2bb1c68dc..bdad01489 100644 --- a/PGate.h +++ b/PGate.h @@ -1,7 +1,7 @@ #ifndef IVL_PGate_H #define IVL_PGate_H /* - * Copyright (c) 1998-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -57,7 +57,7 @@ class PGate : public PNamedItem { explicit PGate(perm_string name, std::list*pins); - virtual ~PGate(); + virtual ~PGate() override; void set_ranges(std::list*ranges); bool is_array() const { return ranges_ != 0; } @@ -90,7 +90,7 @@ class PGate : public PNamedItem { virtual void elaborate_scope(Design*des, NetScope*sc) const; virtual bool elaborate_sig(Design*des, NetScope*scope) const; - SymbolType symbol_type() const; + SymbolType symbol_type() const override; protected: const std::vector& get_pins() const { return pins_; } @@ -127,11 +127,11 @@ class PGAssign : public PGate { public: explicit PGAssign(std::list*pins); explicit PGAssign(std::list*pins, std::list*dels); - ~PGAssign(); + ~PGAssign() override; - void dump(std::ostream&out, unsigned ind =4) const; - virtual void elaborate(Design*des, NetScope*scope) const; - virtual bool elaborate_sig(Design*des, NetScope*scope) const; + void dump(std::ostream&out, unsigned ind =4) const override; + virtual void elaborate(Design*des, NetScope*scope) const override; + virtual bool elaborate_sig(Design*des, NetScope*scope) const override; private: void elaborate_unpacked_array_(Design*des, NetScope*scope, NetNet*lval) const; @@ -163,14 +163,14 @@ class PGBuiltin : public PGate { explicit PGBuiltin(Type t, perm_string name, std::list*pins, PExpr*del); - ~PGBuiltin(); + ~PGBuiltin() override; Type type() const { return type_; } const char * gate_name() const; - virtual void dump(std::ostream&out, unsigned ind =4) const; - virtual void elaborate(Design*, NetScope*scope) const; - virtual bool elaborate_sig(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind =4) const override; + virtual void elaborate(Design*, NetScope*scope) const override; + virtual bool elaborate_sig(Design*des, NetScope*scope) const override; private: void calculate_gate_and_lval_count_(unsigned&gate_count, @@ -210,7 +210,7 @@ class PGModule : public PGate { // constructor. explicit PGModule(Module*type, perm_string name); - ~PGModule(); + ~PGModule() override; // Parameter overrides can come as an ordered list, or a set // of named expressions. @@ -219,10 +219,10 @@ class PGModule : public PGate { std::map attributes; - virtual void dump(std::ostream&out, unsigned ind =4) const; - virtual void elaborate(Design*, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*sc) const; - virtual bool elaborate_sig(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind =4) const override; + virtual void elaborate(Design*, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*sc) const override; + virtual bool elaborate_sig(Design*des, NetScope*scope) const override; // This returns the module name of this module. It is a // permallocated string. diff --git a/PGenerate.h b/PGenerate.h index 20e73fac8..d2d293262 100644 --- a/PGenerate.h +++ b/PGenerate.h @@ -1,7 +1,7 @@ #ifndef IVL_PGenerate_H #define IVL_PGenerate_H /* - * Copyright (c) 2006-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2006-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -54,7 +54,7 @@ class PGenerate : public PNamedItem, public LexicalScope { public: explicit PGenerate(LexicalScope*parent, unsigned id_number); - ~PGenerate(); + ~PGenerate() override; // Generate schemes have an ID number, for when the scope is // implicit. @@ -112,7 +112,7 @@ class PGenerate : public PNamedItem, public LexicalScope { void dump(std::ostream&out, unsigned indent) const; - SymbolType symbol_type() const; + SymbolType symbol_type() const override; private: void check_for_valid_genvar_value_(long value); diff --git a/PTask.h b/PTask.h index 7ea3e924a..05f02eb3d 100644 --- a/PTask.h +++ b/PTask.h @@ -1,7 +1,7 @@ #ifndef IVL_PTask_H #define IVL_PTask_H /* - * Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -39,9 +39,9 @@ class PTaskFunc : public PScope, public PNamedItem { public: PTaskFunc(perm_string name, LexicalScope*parent); - ~PTaskFunc(); + ~PTaskFunc() override; - bool var_init_needs_explicit_lifetime() const; + bool var_init_needs_explicit_lifetime() const override; void set_ports(std::vector*p); @@ -80,7 +80,7 @@ class PTask : public PTaskFunc { public: explicit PTask(perm_string name, LexicalScope*parent, bool is_auto); - ~PTask(); + ~PTask() override; void set_statement(Statement *s); @@ -91,16 +91,16 @@ class PTask : public PTaskFunc { void elaborate_scope(Design*des, NetScope*scope) const; // Bind the ports to the regs that are the ports. - void elaborate_sig(Design*des, NetScope*scope) const; + void elaborate_sig(Design*des, NetScope*scope) const override; // Elaborate the statement to finish off the task definition. - void elaborate(Design*des, NetScope*scope) const; + void elaborate(Design*des, NetScope*scope) const override; bool is_auto() const { return is_auto_; }; - void dump(std::ostream&, unsigned) const; + void dump(std::ostream&, unsigned) const override; - SymbolType symbol_type() const; + SymbolType symbol_type() const override; private: Statement*statement_; @@ -122,7 +122,7 @@ class PFunction : public PTaskFunc { public: explicit PFunction(perm_string name, LexicalScope*parent, bool is_auto); - ~PFunction(); + ~PFunction() override; void set_statement(Statement *s); void set_return(data_type_t*t); @@ -142,16 +142,16 @@ class PFunction : public PTaskFunc { void elaborate_scope(Design*des, NetScope*scope) const; /* elaborate the ports and return value. */ - void elaborate_sig(Design *des, NetScope*) const; + void elaborate_sig(Design *des, NetScope*) const override; /* Elaborate the behavioral statement. */ - void elaborate(Design *des, NetScope*) const; + void elaborate(Design *des, NetScope*) const override; bool is_auto() const { return is_auto_; }; - void dump(std::ostream&, unsigned) const; + void dump(std::ostream&, unsigned) const override; - SymbolType symbol_type() const; + SymbolType symbol_type() const override; private: data_type_t* return_type_; @@ -174,12 +174,12 @@ class PLet : public PTaskFunc { // FIXME: Should the port list be a vector. Check once implemented completely explicit PLet(perm_string name, LexicalScope*parent, std::list*ports, PExpr*expr); - ~PLet(); + ~PLet() override; - void elaborate_sig(Design*des, NetScope*scope) const { (void)des; (void)scope; } - void elaborate(Design*des, NetScope*scope) const { (void)des; (void)scope; } + void elaborate_sig(Design*des, NetScope*scope) const override { (void)des; (void)scope; } + void elaborate(Design*des, NetScope*scope) const override { (void)des; (void)scope; } - void dump(std::ostream&, unsigned) const; + void dump(std::ostream&, unsigned) const override; private: std::list*ports_; diff --git a/PTimingCheck.h b/PTimingCheck.h index cc5a5c61c..5f7ab8cb7 100644 --- a/PTimingCheck.h +++ b/PTimingCheck.h @@ -1,7 +1,7 @@ #ifndef IVL_PTimingCheck_H #define IVL_PTimingCheck_H /* - * Copyright (c) 2006-2023 Stephen Williams + * Copyright (c) 2006-2025 Stephen Williams * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -52,7 +52,7 @@ class PTimingCheck : public LineInfo { }; PTimingCheck() { } - virtual ~PTimingCheck() { } + virtual ~PTimingCheck() override { } virtual void elaborate(class Design*des, class NetScope*scope) const = 0; @@ -76,7 +76,7 @@ class PRecRem : public PTimingCheck { pform_name_t* delayed_reference, pform_name_t* delayed_data); - ~PRecRem(); + ~PRecRem() override; void elaborate(class Design*des, class NetScope*scope) const override; @@ -114,7 +114,7 @@ class PSetupHold : public PTimingCheck { pform_name_t* delayed_reference, pform_name_t* delayed_data); - ~PSetupHold(); + ~PSetupHold() override; void elaborate(class Design*des, class NetScope*scope) const override; diff --git a/PWire.h b/PWire.h index a63687ac2..f7c8c51ea 100644 --- a/PWire.h +++ b/PWire.h @@ -1,7 +1,7 @@ #ifndef IVL_PWire_H #define IVL_PWire_H /* - * Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -93,7 +93,7 @@ class PWire : public PNamedItem { NetNet* elaborate_sig(Design*, NetScope*scope); - SymbolType symbol_type() const; + SymbolType symbol_type() const override; bool is_net() const { return net_set_; }; bool is_port() const { return port_set_; }; diff --git a/Statement.h b/Statement.h index c0c5e23e5..283d7424d 100644 --- a/Statement.h +++ b/Statement.h @@ -1,7 +1,7 @@ #ifndef IVL_Statement_H #define IVL_Statement_H /* - * Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -53,7 +53,7 @@ class PProcess : public LineInfo { PProcess(ivl_process_type_t t, Statement*st) : type_(t), statement_(st) { } - virtual ~PProcess(); + virtual ~PProcess() override; bool elaborate(Design*des, NetScope*scope) const; @@ -78,7 +78,7 @@ class Statement : virtual public LineInfo { public: Statement() { } - virtual ~Statement() =0; + virtual ~Statement() override =0; virtual void dump(std::ostream&out, unsigned ind) const; virtual NetProc* elaborate(Design*des, NetScope*scope) const; @@ -99,7 +99,7 @@ class PAssign_ : public Statement { bool is_init = false); explicit PAssign_(PExpr*lval, PExpr*de, PExpr*ex); explicit PAssign_(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex); - virtual ~PAssign_() =0; + virtual ~PAssign_() override =0; const PExpr* lval() const { return lval_; } PExpr* rval() const { return rval_; } @@ -139,10 +139,10 @@ class PAssign : public PAssign_ { explicit PAssign(PExpr*lval, PExpr*de, PExpr*ex); explicit PAssign(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex); explicit PAssign(PExpr*lval, PExpr*ex, bool is_constant, bool is_init); - ~PAssign(); + ~PAssign() override; - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; private: NetProc* elaborate_compressed_(Design*des, NetScope*scope) const; @@ -155,10 +155,10 @@ class PAssignNB : public PAssign_ { explicit PAssignNB(PExpr*lval, PExpr*ex); explicit PAssignNB(PExpr*lval, PExpr*de, PExpr*ex); explicit PAssignNB(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex); - ~PAssignNB(); + ~PAssignNB() override; - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; private: NetProc*assign_to_memory_(class NetMemory*, PExpr*, @@ -181,11 +181,11 @@ class PBlock : public PScope, public Statement, public PNamedItem { explicit PBlock(perm_string n, LexicalScope*parent, BL_TYPE t); // If it doesn't have a name, it's not a scope explicit PBlock(BL_TYPE t); - ~PBlock(); + ~PBlock() override; BL_TYPE bl_type() const { return bl_type_; } - bool var_init_needs_explicit_lifetime() const; + bool var_init_needs_explicit_lifetime() const override; // This is only used if this block is the statement list for a // constructor. We look for a PChainConstructor as the first @@ -202,12 +202,12 @@ class PBlock : public PScope, public Statement, public PNamedItem { // block. void push_statement_front(Statement*that); - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; - SymbolType symbol_type() const; + SymbolType symbol_type() const override; private: BL_TYPE bl_type_; @@ -216,8 +216,8 @@ class PBlock : public PScope, public Statement, public PNamedItem { class PBreak : public Statement { public: - void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; }; class PCallTask : public Statement { @@ -226,12 +226,12 @@ class PCallTask : public Statement { explicit PCallTask(PPackage *pkg, const pform_name_t &n, const std::list &parms); explicit PCallTask(const pform_name_t &n, const std::list &parms); explicit PCallTask(perm_string n, const std::list &parms); - ~PCallTask(); + ~PCallTask() override; const pform_name_t& path() const; - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; bool elaborate_elab(Design*des, NetScope*scope) const; @@ -282,12 +282,12 @@ class PCase : public Statement { }; PCase(ivl_case_quality_t, NetCase::TYPE, PExpr*ex, std::vector*); - ~PCase(); + ~PCase() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: ivl_case_quality_t quality_; @@ -305,10 +305,10 @@ class PCAssign : public Statement { public: explicit PCAssign(PExpr*l, PExpr*r); - ~PCAssign(); + ~PCAssign() override; - virtual NetCAssign* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetCAssign* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*lval_; @@ -324,10 +324,10 @@ class PChainConstructor : public Statement { public: explicit PChainConstructor(const std::list &parms); explicit PChainConstructor(const std::vector &parms); - ~PChainConstructor(); + ~PChainConstructor() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; inline const std::vector& chain_args(void) const { return parms_; } @@ -340,12 +340,12 @@ class PCondit : public Statement { public: PCondit(PExpr*ex, Statement*i, Statement*e); - ~PCondit(); + ~PCondit() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*expr_; @@ -360,18 +360,18 @@ class PCondit : public Statement { class PContinue : public Statement { public: - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; }; class PDeassign : public Statement { public: explicit PDeassign(PExpr*l); - ~PDeassign(); + ~PDeassign() override; - virtual NetDeassign* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetDeassign* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*lval_; @@ -381,12 +381,12 @@ class PDelayStatement : public Statement { public: PDelayStatement(PExpr*d, Statement*st); - ~PDelayStatement(); + ~PDelayStatement() override; - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; private: PExpr*delay_; @@ -401,10 +401,10 @@ class PDisable : public Statement { public: explicit PDisable(const pform_name_t&sc); - ~PDisable(); + ~PDisable() override; - virtual void dump(std::ostream&out, unsigned ind) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; + virtual void dump(std::ostream&out, unsigned ind) const override; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; private: pform_name_t scope_; @@ -414,12 +414,12 @@ class PDoWhile : public Statement { public: PDoWhile(PExpr*ex, Statement*st); - ~PDoWhile(); + ~PDoWhile() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*cond_; @@ -444,17 +444,17 @@ class PEventStatement : public Statement { // from functions added and outputs removed for always_comb/latch. explicit PEventStatement(bool always_sens = false); - ~PEventStatement(); + ~PEventStatement() override; void set_statement(Statement*st); - virtual void dump(std::ostream&out, unsigned ind) const; + virtual void dump(std::ostream&out, unsigned ind) const override; // Call this with a NULL statement only. It is used to print // the event expression for inter-assignment event controls. virtual void dump_inline(std::ostream&out) const; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; bool has_aa_term(Design*des, NetScope*scope); @@ -477,10 +477,10 @@ class PForce : public Statement { public: explicit PForce(PExpr*l, PExpr*r); - ~PForce(); + ~PForce() override; - virtual NetForce* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetForce* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*lval_; @@ -490,12 +490,12 @@ class PForce : public Statement { class PForeach : public Statement { public: explicit PForeach(perm_string var, const std::list&ix, Statement*stmt); - ~PForeach(); + ~PForeach() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: NetProc* elaborate_static_array_(Design*des, NetScope*scope, @@ -510,12 +510,12 @@ class PForeach : public Statement { class PForever : public Statement { public: explicit PForever(Statement*s); - ~PForever(); + ~PForever() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: Statement*statement_; @@ -526,12 +526,12 @@ class PForStatement : public Statement { public: PForStatement(PExpr*n1, PExpr*e1, PExpr*cond, Statement*step, Statement*body); - ~PForStatement(); + ~PForStatement() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr* name1_; @@ -548,18 +548,18 @@ class PNoop : public Statement { public: PNoop() { } - ~PNoop() { } + ~PNoop() override { } }; class PRepeat : public Statement { public: explicit PRepeat(PExpr*expr, Statement*s); - ~PRepeat(); + ~PRepeat() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*expr_; @@ -570,10 +570,10 @@ class PRelease : public Statement { public: explicit PRelease(PExpr*l); - ~PRelease(); + ~PRelease() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*lval_; @@ -583,10 +583,10 @@ class PReturn : public Statement { public: explicit PReturn(PExpr*e); - ~PReturn(); + ~PReturn() override; - NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*expr_; @@ -600,10 +600,10 @@ class PTrigger : public Statement { public: explicit PTrigger(PPackage*pkg, const pform_name_t&ev, unsigned lexical_pos); - ~PTrigger(); + ~PTrigger() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: pform_scoped_name_t event_; @@ -613,10 +613,10 @@ class PTrigger : public Statement { class PNBTrigger : public Statement { public: explicit PNBTrigger(const pform_name_t&ev, unsigned lexical_pos, PExpr*dly); - ~PNBTrigger(); + ~PNBTrigger() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: pform_name_t event_; @@ -628,12 +628,12 @@ class PWhile : public Statement { public: PWhile(PExpr*ex, Statement*st); - ~PWhile(); + ~PWhile() override; - virtual NetProc* elaborate(Design*des, NetScope*scope) const; - virtual void elaborate_scope(Design*des, NetScope*scope) const; - virtual void elaborate_sig(Design*des, NetScope*scope) const; - virtual void dump(std::ostream&out, unsigned ind) const; + virtual NetProc* elaborate(Design*des, NetScope*scope) const override; + virtual void elaborate_scope(Design*des, NetScope*scope) const override; + virtual void elaborate_sig(Design*des, NetScope*scope) const override; + virtual void dump(std::ostream&out, unsigned ind) const override; private: PExpr*cond_; diff --git a/cadpli/Makefile.in b/cadpli/Makefile.in index e1d2ac69e..f10004601 100644 --- a/cadpli/Makefile.in +++ b/cadpli/Makefile.in @@ -59,7 +59,11 @@ distclean: clean rm -f Makefile config.log cppcheck: $(O:.o=.c) - cppcheck --enable=all --std=c99 --std=c++11 -f $(INCLUDE_PATH) $^ + cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/../cppcheck-global.sup \ + --suppressions-list=$(srcdir)/cppcheck.sup \ + $(INCLUDE_PATH) $^ Makefile: $(srcdir)/Makefile.in ../config.status cd ..; ./config.status --file=cadpli/$@ diff --git a/cadpli/cppcheck.sup b/cadpli/cppcheck.sup new file mode 100644 index 000000000..d08cd7dd5 --- /dev/null +++ b/cadpli/cppcheck.sup @@ -0,0 +1,7 @@ +// We use guarded memory allocation routines, but cppcheck is not +// noticing this so it is complaining we could return a NULL value. +nullPointerOutOfMemory:cadpli.c:53 +nullPointerOutOfMemory:cadpli.c:54 + +// Unused function +unusedFunction:ivl_dlfcn.h:73 diff --git a/discipline.h b/discipline.h index 677b25772..8484b8212 100644 --- a/discipline.h +++ b/discipline.h @@ -1,7 +1,7 @@ #ifndef IVL_discipline_H #define IVL_discipline_H /* - * Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2008-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -36,7 +36,7 @@ extern std::ostream& operator << (std::ostream&, ivl_dis_domain_t); class ivl_nature_s : public LineInfo { public: explicit ivl_nature_s(perm_string name, perm_string access); - ~ivl_nature_s(); + ~ivl_nature_s() override; perm_string name() const { return name_; } // Identifier for the access function for this nature @@ -51,12 +51,12 @@ class ivl_discipline_s : public LineInfo { public: explicit ivl_discipline_s (perm_string name, ivl_dis_domain_t dom, ivl_nature_t pot, ivl_nature_t flow); - ~ivl_discipline_s(); + ~ivl_discipline_s() override; - perm_string name() const { return name_; } - ivl_dis_domain_t domain() const { return domain_; } - ivl_nature_t potential() const { return potential_; } - ivl_nature_t flow() const { return flow_; } + perm_string name() const { return name_; } + ivl_dis_domain_t domain() const { return domain_; } + ivl_nature_t potential() const { return potential_; } + ivl_nature_t flow() const { return flow_; } private: perm_string name_; diff --git a/driver-vpi/Makefile.in b/driver-vpi/Makefile.in index 799dcf591..a54771a4b 100644 --- a/driver-vpi/Makefile.in +++ b/driver-vpi/Makefile.in @@ -66,7 +66,10 @@ distclean: clean rm -f Makefile config.log cppcheck: main.c - cppcheck --enable=all --std=c99 --std=c++11 -f $(INCLUDE_PATH) $^ + cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/../cppcheck-global.sup \ + $(INCLUDE_PATH) $^ Makefile: $(srcdir)/Makefile.in ../config.status cd ..; ./config.status --file=driver-vpi/$@ diff --git a/ivl_alloc.h b/ivl_alloc.h index 181a2544a..58670eab0 100644 --- a/ivl_alloc.h +++ b/ivl_alloc.h @@ -1,7 +1,7 @@ #ifndef IVL_ivl_alloc_H #define IVL_ivl_alloc_H /* - * Copyright (C) 2010-2014 Cary R. (cygcary@yahoo.com) + * Copyright (C) 2010-2025 Cary R. (cygcary@yahoo.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,12 +21,30 @@ #ifdef __cplusplus # include # include +# include #else # include # include +# include #endif #if defined(__GNUC__) +/* + * Define a safer version of strdup(). + */ + +#define strdup(__ivl_str) \ +({ \ + char *__ivl_rtn = strdup(__ivl_str); \ + /* If we run out of memory then exit with a message. */ \ + if (__ivl_rtn == NULL) { \ + fprintf(stderr, "%s:%d: Error: strdup() ran out of memory.\n", \ + __FILE__, __LINE__); \ + exit(1); \ + } \ + __ivl_rtn; \ +}) + /* * Define a safer version of malloc(). */ diff --git a/ivlpp/Makefile.in b/ivlpp/Makefile.in index c5580b665..0ec200711 100644 --- a/ivlpp/Makefile.in +++ b/ivlpp/Makefile.in @@ -60,7 +60,10 @@ distclean: clean rm -f Makefile config.log cppcheck: $(O:.o=.c) - cppcheck --enable=all --std=c99 --std=c++11 -f $(INCLUDE_PATH) $^ + cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/../cppcheck-global.sup \ + $(INCLUDE_PATH) $^ Makefile: $(srcdir)/Makefile.in ../config.status cd ..; ./config.status --file=ivlpp/$@ diff --git a/ivlpp/main.c b/ivlpp/main.c index 714395ec1..4fb32d814 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -73,7 +73,7 @@ unsigned vhdlpp_libdir_cnt = 0; static char**source_list = 0; static unsigned source_cnt = 0; -void add_source_file(const char*name) +static void add_source_file(const char*name) { if (source_list == 0) { source_list = calloc(2, sizeof(char*)); diff --git a/libveriuser/Makefile.in b/libveriuser/Makefile.in index 112e6384e..2b27ad265 100644 --- a/libveriuser/Makefile.in +++ b/libveriuser/Makefile.in @@ -77,6 +77,8 @@ distclean: clean cppcheck: $(O:.o=.c) cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/../cppcheck-global.sup \ --suppressions-list=$(srcdir)/cppcheck.sup \ --relative-paths=$(srcdir) $(INCLUDE_PATH) $^ diff --git a/libveriuser/a_handle_object.c b/libveriuser/a_handle_object.c index aa59478f8..f33886c4f 100644 --- a/libveriuser/a_handle_object.c +++ b/libveriuser/a_handle_object.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -38,7 +38,7 @@ handle acc_handle_object(const char*name) char* acc_set_scope(handle ref, ...) { - char*name; + const char*name; search_scope = ref; name = acc_fetch_fullname(search_scope); diff --git a/libveriuser/cppcheck.sup b/libveriuser/cppcheck.sup index 446383c12..fd010f360 100644 --- a/libveriuser/cppcheck.sup +++ b/libveriuser/cppcheck.sup @@ -1,3 +1,19 @@ +// We use guarded memory allocation routines, but cppcheck is not +// noticing this so it is complaining we could return a NULL value. +nullPointerOutOfMemory:workarea.c:53 // calloc @ 52 +nullPointerOutOfMemory:workarea.c:54 // calloc @ 52 +nullPointerOutOfMemory:workarea.c:55 // calloc @ 52 +nullPointerOutOfMemory:veriusertfs.c:61 // calloc @ 70 +nullPointerOutOfMemory:veriusertfs.c:62 // calloc @ 70 +nullPointerOutOfMemory:veriusertfs.c:63 // calloc @ 70 +nullPointerOutOfMemory:a_vcl.c:167 // strdup @ 166 +nullPointerOutOfMemory:a_vcl.c:168 // strdup @ 166 +nullPointerOutOfMemory:a_vcl.c:169 // strdup @ 166 +nullPointerOutOfMemory:a_vcl.c:170 // strdup @ 166 +nullPointerOutOfMemory:a_vcl.c:171 // strdup @ 166 +nullPointerOutOfMemory:a_vcl.c:180 // strdup @ 166 +memleakOnRealloc:veriusertfs.c:66 + // These are the functions that the runtime exports. // The ACC functions. diff --git a/libveriuser/mc_scan_plusargs.c b/libveriuser/mc_scan_plusargs.c index 965050740..1e2afc1fa 100644 --- a/libveriuser/mc_scan_plusargs.c +++ b/libveriuser/mc_scan_plusargs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2013 Michael Ruff (mruff at chiaro.com) + * Copyright (c) 2002-2025 Michael Ruff (mruff at chiaro.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -24,7 +24,7 @@ /* * mc_scan_plusargs implemented using VPI interface */ -char *mc_scan_plusargs(char *plusarg) +char *mc_scan_plusargs(const char *plusarg) { int argc, diff; char **argv; @@ -37,7 +37,8 @@ char *mc_scan_plusargs(char *plusarg) /* for each argument */ argv = vpi_vlog_info.argv; for (argc = 0; argc < vpi_vlog_info.argc; argc++, argv++) { - char *a, *p; + char *a; + const char *p; a = *argv; p = plusarg; diff --git a/main.cc b/main.cc index c7925a58e..48cd73d98 100644 --- a/main.cc +++ b/main.cc @@ -95,7 +95,10 @@ static void signals_handler(int sig) unsigned flag_errors = 0; static unsigned long pre_process_fail_count = 0; -const char*basedir = strdup("."); +// We have to wrap the strdup() so that the define expands correctly. +static char* init_basedir(void) +{ return strdup("."); } +const char*basedir = init_basedir(); /* * These are the language support control flags. These support which @@ -130,10 +133,10 @@ void add_vpi_module(const char*name) vpi_module_list = strdup(name); } else { - char*tmp = (char*)realloc(vpi_module_list, - strlen(vpi_module_list) - + strlen(name) - + 2); + char*tmp = static_cast(realloc(vpi_module_list, + strlen(vpi_module_list) + + strlen(name) + + 2)); strcat(tmp, ","); strcat(tmp, name); vpi_module_list = tmp; @@ -647,7 +650,7 @@ static void read_iconfig_file(const char*ipath) } if (strcmp(buf, "basedir") == 0) { - free((void *)basedir); + free(static_cast(const_cast(basedir))); basedir = strdup(cp); } else if (strcmp(buf, "debug") == 0) { @@ -715,7 +718,7 @@ static void read_iconfig_file(const char*ipath) add_vpi_module(cp); } else if (strcmp(buf, "out") == 0) { - free((void *)flags["-o"]); + free(reinterpret_cast(const_cast(flags["-o"]))); flags["-o"] = strdup(cp); } else if (strcmp(buf, "sys_func") == 0) { @@ -861,7 +864,7 @@ static void read_sources_file(const char*path) extern Design* elaborate(list root); #if defined(HAVE_TIMES) -static double cycles_diff(struct tms *a, struct tms *b) +static double cycles_diff(const struct tms *a, const struct tms *b) { clock_t aa = a->tms_utime + a->tms_stime @@ -892,13 +895,13 @@ static void EOC_cleanup(void) } library_suff.clear(); - free((void *) basedir); + free(reinterpret_cast(const_cast(basedir))); free(ivlpp_string); free(depfile_name); for (map::iterator flg = flags.begin() ; flg != flags.end() ; ++ flg ) { - free((void *)flg->second); + free(reinterpret_cast(const_cast(flg->second))); } flags.clear(); @@ -1397,7 +1400,7 @@ static void find_module_mention(map&check_map, Module*mod) list gates = mod->get_gates(); list::const_iterator gate; for (gate = gates.begin(); gate != gates.end(); ++ gate ) { - PGModule*tmp = dynamic_cast(*gate); + const PGModule*tmp = dynamic_cast(*gate); if (tmp) { // Note that this module has been instantiated check_map[tmp->get_type()] = true; @@ -1415,7 +1418,7 @@ static void find_module_mention(map&check_map, PGenerate*schm) { list::const_iterator gate; for (gate = schm->gates.begin(); gate != schm->gates.end(); ++ gate ) { - PGModule*tmp = dynamic_cast(*gate); + const PGModule*tmp = dynamic_cast(*gate); if (tmp) { // Note that this module has been instantiated check_map[tmp->get_type()] = true; diff --git a/netlist.h b/netlist.h index 8e453a4eb..46a24ccec 100644 --- a/netlist.h +++ b/netlist.h @@ -1,7 +1,7 @@ #ifndef IVL_netlist_H #define IVL_netlist_H /* - * Copyright (c) 1998-2024 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -4011,18 +4011,18 @@ class NetEAccess : public NetExpr { public: explicit NetEAccess(NetBranch*br, ivl_nature_t nat); - ~NetEAccess(); + ~NetEAccess() override; ivl_nature_t get_nature() const { return nature_; } NetBranch* get_branch() const { return branch_; } - virtual ivl_variable_type_t expr_type() const; - virtual void dump(std::ostream&) const; + virtual ivl_variable_type_t expr_type() const override; + virtual void dump(std::ostream&) const override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetEAccess*dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetEAccess*dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; private: NetBranch*branch_; @@ -4038,19 +4038,19 @@ class NetUTask : public NetProc { public: explicit NetUTask(NetScope*); - ~NetUTask(); + ~NetUTask() override; const std::string name() const; const NetScope* task() const; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual void nex_output(NexusSet&); - virtual bool emit_proc(struct target_t*) const; - virtual void dump(std::ostream&, unsigned ind) const; - virtual DelayType delay_type(bool print_delay=false) const; - virtual bool check_synth(ivl_process_type_t pr_type, const NetScope*scope) const; + bool nested_func = false) const override; + virtual void nex_output(NexusSet&) override; + virtual bool emit_proc(struct target_t*) const override; + virtual void dump(std::ostream&, unsigned ind) const override; + virtual DelayType delay_type(bool print_delay=false) const override; + virtual bool check_synth(ivl_process_type_t pr_type, const NetScope*scope) const override; private: NetScope*task_; @@ -4072,14 +4072,14 @@ class NetWhile : public NetProc { void emit_proc_recurse(struct target_t*) const; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual void nex_output(NexusSet&); - virtual bool emit_proc(struct target_t*) const; - virtual void dump(std::ostream&, unsigned ind) const; - virtual DelayType delay_type(bool print_delay=false) const; - virtual bool check_synth(ivl_process_type_t pr_type, const NetScope*scope) const; + bool nested_func = false) const override; + virtual void nex_output(NexusSet&) override; + virtual bool emit_proc(struct target_t*) const override; + virtual void dump(std::ostream&, unsigned ind) const override; + virtual DelayType delay_type(bool print_delay=false) const override; + virtual bool check_synth(ivl_process_type_t pr_type, const NetScope*scope) const override; virtual bool evaluate_function(const LineInfo&loc, - std::map&ctx) const; + std::map&ctx) const override; private: NetExpr*cond_; @@ -4096,7 +4096,7 @@ class NetProcTop : public LineInfo, public Attrib { public: NetProcTop(NetScope*s, ivl_process_type_t t, class NetProc*st); - ~NetProcTop(); + ~NetProcTop() override; ivl_process_type_t type() const { return type_; } NetProc*statement(); @@ -4141,7 +4141,7 @@ class NetAnalogTop : public LineInfo, public Attrib { public: NetAnalogTop(NetScope*scope, ivl_process_type_t t, NetProc*st); - ~NetAnalogTop(); + ~NetAnalogTop() override; ivl_process_type_t type() const { return type_; } @@ -4200,7 +4200,7 @@ class NetEBinary : public NetExpr { public: NetEBinary(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBinary(); + ~NetEBinary() override; const NetExpr*left() const { return left_; } const NetExpr*right() const { return right_; } @@ -4210,17 +4210,17 @@ class NetEBinary : public NetExpr { // A binary expression node only has a definite // self-determinable width if the operands both have definite // widths. - virtual bool has_width() const; + virtual bool has_width() const override; - virtual NetEBinary* dup_expr() const; - virtual NetExpr* eval_tree(); + virtual NetEBinary* dup_expr() const override; + virtual NetExpr* eval_tree() override; virtual NetExpr* evaluate_function(const LineInfo&loc, - std::map&ctx) const; + std::map&ctx) const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual void dump(std::ostream&) const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual void dump(std::ostream&) const override; protected: char op_; @@ -4241,16 +4241,16 @@ class NetEBAdd : public NetEBinary { public: NetEBAdd(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBAdd(); + ~NetEBAdd() override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual NetEBAdd* dup_expr() const; - virtual NetExpr* eval_tree(); - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + virtual NetEBAdd* dup_expr() const override; + virtual NetExpr* eval_tree() override; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; private: - virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const; + virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const override; NetECReal* eval_tree_real_(const NetExpr*l, const NetExpr*r) const; }; @@ -4263,15 +4263,15 @@ class NetEBDiv : public NetEBinary { public: NetEBDiv(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBDiv(); + ~NetEBDiv() override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual NetEBDiv* dup_expr() const; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + virtual NetEBDiv* dup_expr() const override; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; private: - virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const; + virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const override; NetExpr* eval_tree_real_(const NetExpr*l, const NetExpr*r) const; }; @@ -4293,7 +4293,7 @@ class NetEBBits : public NetEBinary { public: NetEBBits(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBBits(); + ~NetEBBits() override; virtual NetEBBits* dup_expr() const override; virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; @@ -4322,18 +4322,18 @@ class NetEBComp : public NetEBinary { public: NetEBComp(char op, NetExpr*l, NetExpr*r); - ~NetEBComp(); + ~NetEBComp() override; /* A compare expression has a definite width. */ - virtual bool has_width() const; - virtual ivl_variable_type_t expr_type() const; - virtual NetEBComp* dup_expr() const; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + virtual bool has_width() const override; + virtual ivl_variable_type_t expr_type() const override; + virtual NetEBComp* dup_expr() const override; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; private: NetEConst* must_be_leeq_(const NetExpr*le, const verinum&rv, bool eq_flag) const; - virtual NetEConst*eval_arguments_(const NetExpr*le, const NetExpr*re) const; + virtual NetEConst*eval_arguments_(const NetExpr*le, const NetExpr*re) const override; NetEConst*eval_eqeq_(bool ne_flag, const NetExpr*le, const NetExpr*re) const; NetEConst*eval_eqeq_real_(bool ne_flag, const NetExpr*le, const NetExpr*re) const; NetEConst*eval_less_(const NetExpr*le, const NetExpr*re) const; @@ -4378,12 +4378,12 @@ class NetEBMinMax : public NetEBinary { public: NetEBMinMax(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBMinMax(); + ~NetEBMinMax() override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; private: - virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const; + virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const override; NetExpr* eval_tree_real_(const NetExpr*l, const NetExpr*r) const; }; @@ -4394,15 +4394,15 @@ class NetEBMult : public NetEBinary { public: NetEBMult(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBMult(); + ~NetEBMult() override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual NetEBMult* dup_expr() const; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + virtual NetEBMult* dup_expr() const override; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; private: - virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const; + virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const override; NetExpr* eval_tree_real_(const NetExpr*l, const NetExpr*r) const; }; @@ -4413,15 +4413,15 @@ class NetEBPow : public NetEBinary { public: NetEBPow(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBPow(); + ~NetEBPow() override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual NetEBPow* dup_expr() const; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + virtual NetEBPow* dup_expr() const override; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; private: - virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const; + virtual NetExpr* eval_arguments_(const NetExpr*l, const NetExpr*r) const override; NetExpr* eval_tree_real_(const NetExpr*l, const NetExpr*r) const; }; @@ -4437,7 +4437,7 @@ class NetEBShift : public NetEBinary { public: NetEBShift(char op, NetExpr*l, NetExpr*r, unsigned wid, bool signed_flag); - ~NetEBShift(); + ~NetEBShift() override; // A shift expression only needs the left expression to have a // definite width to give the expression a definite width. @@ -4466,7 +4466,7 @@ class NetEConcat : public NetExpr { public: NetEConcat(unsigned cnt, unsigned repeat, ivl_variable_type_t vt); - ~NetEConcat(); + ~NetEConcat() override; // Manipulate the parameters. void set(unsigned idx, NetExpr*e); @@ -4475,16 +4475,16 @@ class NetEConcat : public NetExpr { unsigned nparms() const { return parms_.size() ; } NetExpr* parm(unsigned idx) const { return parms_[idx]; } - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual NetEConcat* dup_expr() const; - virtual NetEConst* eval_tree(); + bool nested_func = false) const override; + virtual NetEConcat* dup_expr() const override; + virtual NetEConst* eval_tree() override; virtual NetExpr* evaluate_function(const LineInfo&loc, - std::map&ctx) const; - virtual NetNet*synthesize(Design*, NetScope*scope, NetExpr*root); - virtual void expr_scan(struct expr_scan_t*) const; - virtual void dump(std::ostream&) const; + std::map&ctx) const override; + virtual NetNet*synthesize(Design*, NetScope*scope, NetExpr*root) override; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual void dump(std::ostream&) const override; private: std::vectorparms_; @@ -4520,7 +4520,7 @@ class NetESelect : public NetExpr { ivl_select_type_t sel_type = IVL_SEL_OTHER); NetESelect(NetExpr*exp, NetExpr*base, unsigned wid, ivl_type_t use_type); - ~NetESelect(); + ~NetESelect() override; const NetExpr*sub_expr() const; const NetExpr*select() const; @@ -4529,17 +4529,17 @@ class NetESelect : public NetExpr { // The type of a bit/part select is the base type of the // sub-expression. The type of an array/member select is // the base type of the element/member. - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetEConst* eval_tree(); + bool nested_func = false) const override; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetEConst* eval_tree() override; virtual NetExpr*evaluate_function(const LineInfo&loc, - std::map&ctx) const; + std::map&ctx) const override; virtual NetESelect* dup_expr() const; - virtual NetNet*synthesize(Design*des, NetScope*scope, NetExpr*root); - virtual void dump(std::ostream&) const; + virtual NetNet*synthesize(Design*des, NetScope*scope, NetExpr*root) override; + virtual void dump(std::ostream&) const override; private: NetExpr*expr_; @@ -4554,16 +4554,16 @@ class NetEEvent : public NetExpr { public: explicit NetEEvent(NetEvent*); - ~NetEEvent(); + ~NetEEvent() override; const NetEvent* event() const; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetEEvent* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetEEvent* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; private: NetEvent*event_; @@ -4578,16 +4578,16 @@ class NetENetenum : public NetExpr { public: explicit NetENetenum(const netenum_t*); - ~NetENetenum(); + ~NetENetenum() override; const netenum_t* netenum() const; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetENetenum* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetENetenum* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; private: const netenum_t*netenum_; @@ -4599,19 +4599,19 @@ class NetENew : public NetExpr { explicit NetENew(ivl_type_t); // dynamic array of objects. explicit NetENew(ivl_type_t, NetExpr*size, NetExpr* init_val=0); - ~NetENew(); + ~NetENew() override; inline const NetExpr*size_expr() const { return size_; } inline const NetExpr*init_expr() const { return init_val_; } - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetENew* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetENew* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; private: NetExpr*size_; @@ -4626,14 +4626,14 @@ class NetENull : public NetExpr { public: NetENull(); - ~NetENull(); + ~NetENull() override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetENull* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetENull* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; }; /* @@ -4647,19 +4647,19 @@ class NetENull : public NetExpr { class NetEProperty : public NetExpr { public: NetEProperty(NetNet*n, size_t pidx_, NetExpr*canon_index =0); - ~NetEProperty(); + ~NetEProperty() override; inline const NetNet* get_sig() const { return net_; } inline size_t property_idx() const { return pidx_; } inline const NetExpr*get_index() const { return index_; } public: // Overridden methods - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetEProperty* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetEProperty* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; private: NetNet*net_; @@ -4676,16 +4676,16 @@ class NetEScope : public NetExpr { public: explicit NetEScope(NetScope*); - ~NetEScope(); + ~NetEScope() override; const NetScope* scope() const; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetEScope* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetEScope* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; private: NetScope*scope_; @@ -4702,7 +4702,7 @@ class NetESFunc : public NetExpr { NetESFunc(const char*name, ivl_variable_type_t t, unsigned width, unsigned nprms, bool is_overridden =false); NetESFunc(const char*name, ivl_type_t rtype, unsigned nprms); - ~NetESFunc(); + ~NetESFunc() override; const char* name() const; @@ -4711,18 +4711,18 @@ class NetESFunc : public NetExpr { NetExpr* parm(unsigned idx); const NetExpr* parm(unsigned idx) const; - virtual NetExpr* eval_tree(); + virtual NetExpr* eval_tree() override; virtual NetExpr* evaluate_function(const LineInfo&loc, - std::map&ctx) const; + std::map&ctx) const override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual void dump(std::ostream&) const; + bool nested_func = false) const override; + virtual void dump(std::ostream&) const override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetESFunc*dup_expr() const; - virtual NetNet*synthesize(Design*, NetScope*scope, NetExpr*root); + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetESFunc*dup_expr() const override; + virtual NetNet*synthesize(Design*, NetScope*scope, NetExpr*root) override; private: /* Use the 32 bit ID as follows: @@ -4844,16 +4844,16 @@ class NetEShallowCopy : public NetExpr { public: // Make a shallow copy from arg2 into arg1. explicit NetEShallowCopy(NetExpr*arg1, NetExpr*arg2); - ~NetEShallowCopy(); + ~NetEShallowCopy() override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual NetEShallowCopy* dup_expr() const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual NetEShallowCopy* dup_expr() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; - virtual void dump(std::ostream&os) const; + virtual void dump(std::ostream&os) const override; void expr_scan_oper1(struct expr_scan_t*) const; void expr_scan_oper2(struct expr_scan_t*) const; @@ -4872,24 +4872,24 @@ class NetETernary : public NetExpr { public: NetETernary(NetExpr*c, NetExpr*t, NetExpr*f, unsigned wid, bool signed_flag); - ~NetETernary(); + ~NetETernary() override; - const netenum_t* enumeration() const; + const netenum_t* enumeration() const override; const NetExpr*cond_expr() const; const NetExpr*true_expr() const; const NetExpr*false_expr() const; - virtual NetETernary* dup_expr() const; - virtual NetExpr* eval_tree(); + virtual NetETernary* dup_expr() const override; + virtual NetExpr* eval_tree() override; virtual NetExpr*evaluate_function(const LineInfo&loc, - std::map&ctx) const; - virtual ivl_variable_type_t expr_type() const; + std::map&ctx) const override; + virtual ivl_variable_type_t expr_type() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual void expr_scan(struct expr_scan_t*) const; - virtual void dump(std::ostream&) const; - virtual NetNet*synthesize(Design*, NetScope*scope, NetExpr*root); + bool nested_func = false) const override; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual void dump(std::ostream&) const override; + virtual NetNet*synthesize(Design*, NetScope*scope, NetExpr*root) override; public: static bool test_operand_compat(ivl_variable_type_t tru, ivl_variable_type_t fal); @@ -4929,22 +4929,22 @@ class NetEUnary : public NetExpr { public: NetEUnary(char op, NetExpr*ex, unsigned wid, bool signed_flag); - ~NetEUnary(); + ~NetEUnary() override; char op() const { return op_; } const NetExpr* expr() const { return expr_; } - virtual NetEUnary* dup_expr() const; - virtual NetExpr* eval_tree(); + virtual NetEUnary* dup_expr() const override; + virtual NetExpr* eval_tree() override; virtual NetExpr* evaluate_function(const LineInfo&loc, - std::map&ctx) const; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + std::map&ctx) const override; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; - virtual void expr_scan(struct expr_scan_t*) const; - virtual void dump(std::ostream&) const; + bool nested_func = false) const override; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual void dump(std::ostream&) const override; protected: char op_; @@ -4959,42 +4959,42 @@ class NetEUBits : public NetEUnary { public: NetEUBits(char op, NetExpr*ex, unsigned wid, bool signed_flag); - ~NetEUBits(); + ~NetEUBits() override; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; - virtual NetEUBits* dup_expr() const; - virtual ivl_variable_type_t expr_type() const; + virtual NetEUBits* dup_expr() const override; + virtual ivl_variable_type_t expr_type() const override; }; class NetEUReduce : public NetEUnary { public: NetEUReduce(char op, NetExpr*ex); - ~NetEUReduce(); + ~NetEUReduce() override; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); - virtual NetEUReduce* dup_expr() const; - virtual ivl_variable_type_t expr_type() const; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; + virtual NetEUReduce* dup_expr() const override; + virtual ivl_variable_type_t expr_type() const override; private: - virtual NetEConst* eval_arguments_(const NetExpr*ex) const; - virtual NetEConst* eval_tree_real_(const NetExpr*ex) const; + virtual NetEConst* eval_arguments_(const NetExpr*ex) const override; + virtual NetEConst* eval_tree_real_(const NetExpr*ex) const override; }; class NetECast : public NetEUnary { public: NetECast(char op, NetExpr*ex, unsigned wid, bool signed_flag); - ~NetECast(); + ~NetECast() override; - virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root); - virtual NetECast* dup_expr() const; - virtual ivl_variable_type_t expr_type() const; - virtual void dump(std::ostream&) const; + virtual NetNet* synthesize(Design*, NetScope*scope, NetExpr*root) override; + virtual NetECast* dup_expr() const override; + virtual ivl_variable_type_t expr_type() const override; + virtual void dump(std::ostream&) const override; private: - virtual NetExpr* eval_arguments_(const NetExpr*ex) const; + virtual NetExpr* eval_arguments_(const NetExpr*ex) const override; }; /* @@ -5012,19 +5012,19 @@ class NetESignal : public NetExpr { public: explicit NetESignal(NetNet*n); NetESignal(NetNet*n, NetExpr*word_index); - ~NetESignal(); + ~NetESignal() override; perm_string name() const; - virtual NetESignal* dup_expr() const; - NetNet* synthesize(Design*des, NetScope*scope, NetExpr*root); + virtual NetESignal* dup_expr() const override; + NetNet* synthesize(Design*des, NetScope*scope, NetExpr*root) override; NexusSet* nex_input(bool rem_out = true, bool always_sens = false, - bool nested_func = false) const; + bool nested_func = false) const override; NexusSet* nex_input_base(bool rem_out, bool always_sens, bool nested_func, unsigned base, unsigned width) const; virtual NetExpr*evaluate_function(const LineInfo&loc, - std::map&ctx) const; + std::map&ctx) const override; // This is the expression for selecting an array word, if this // signal refers to an array. @@ -5039,10 +5039,10 @@ class NetESignal : public NetExpr { long msi() const; long lsi() const; - virtual ivl_variable_type_t expr_type() const; + virtual ivl_variable_type_t expr_type() const override; - virtual void expr_scan(struct expr_scan_t*) const; - virtual void dump(std::ostream&) const; + virtual void expr_scan(struct expr_scan_t*) const override; + virtual void dump(std::ostream&) const override; private: NetNet*net_; diff --git a/t-dll.h b/t-dll.h index 9ae6fd58a..6107d7c4b 100644 --- a/t-dll.h +++ b/t-dll.h @@ -1,7 +1,7 @@ #ifndef IVL_t_dll_H #define IVL_t_dll_H /* - * Copyright (c) 2000-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -53,52 +53,52 @@ struct dll_target : public target_t, public expr_scan_t { // version of a loadable target code generator. void test_version(const char*target_name); - bool start_design(const Design*); - int end_design(const Design*); + bool start_design(const Design*) override; + int end_design(const Design*) override; - bool bufz(const NetBUFZ*); - bool branch(const NetBranch*); - bool class_type(const NetScope*, netclass_t*); - bool enumeration(const NetScope*, netenum_t*); - void event(const NetEvent*); - void logic(const NetLogic*); - bool tran(const NetTran*); - bool ureduce(const NetUReduce*); - void net_case_cmp(const NetCaseCmp*); - void udp(const NetUDP*); - void lpm_abs(const NetAbs*); - void lpm_add_sub(const NetAddSub*); - bool lpm_array_dq(const NetArrayDq*); - bool lpm_cast_int2(const NetCastInt2*); - bool lpm_cast_int4(const NetCastInt4*); - bool lpm_cast_real(const NetCastReal*); - void lpm_clshift(const NetCLShift*); - void lpm_compare(const NetCompare*); - void lpm_divide(const NetDivide*); - void lpm_ff(const NetFF*); - void lpm_latch(const NetLatch*); - void lpm_modulo(const NetModulo*); - void lpm_mult(const NetMult*); - void lpm_mux(const NetMux*); - void lpm_pow(const NetPow*); - bool concat(const NetConcat*); - bool part_select(const NetPartSelect*); - bool replicate(const NetReplicate*); + bool bufz(const NetBUFZ*) override; + bool branch(const NetBranch*) override; + bool class_type(const NetScope*, netclass_t*) override; + bool enumeration(const NetScope*, netenum_t*) override; + void event(const NetEvent*) override; + void logic(const NetLogic*) override; + bool tran(const NetTran*) override; + bool ureduce(const NetUReduce*) override; + void net_case_cmp(const NetCaseCmp*) override; + void udp(const NetUDP*) override; + void lpm_abs(const NetAbs*) override; + void lpm_add_sub(const NetAddSub*) override; + bool lpm_array_dq(const NetArrayDq*) override; + bool lpm_cast_int2(const NetCastInt2*) override; + bool lpm_cast_int4(const NetCastInt4*) override; + bool lpm_cast_real(const NetCastReal*) override; + void lpm_clshift(const NetCLShift*) override; + void lpm_compare(const NetCompare*) override; + void lpm_divide(const NetDivide*) override; + void lpm_ff(const NetFF*) override; + void lpm_latch(const NetLatch*) override; + void lpm_modulo(const NetModulo*) override; + void lpm_mult(const NetMult*) override; + void lpm_mux(const NetMux*) override; + void lpm_pow(const NetPow*) override; + bool concat(const NetConcat*) override; + bool part_select(const NetPartSelect*) override; + bool replicate(const NetReplicate*) override; void net_assign(const NetAssign_*) const; - bool net_sysfunction(const NetSysFunc*); - bool net_function(const NetUserFunc*); - bool net_const(const NetConst*); - bool net_literal(const NetLiteral*); - void net_probe(const NetEvProbe*); - bool sign_extend(const NetSignExtend*); - bool substitute(const NetSubstitute*); + bool net_sysfunction(const NetSysFunc*) override; + bool net_function(const NetUserFunc*) override; + bool net_const(const NetConst*) override; + bool net_literal(const NetLiteral*) override; + void net_probe(const NetEvProbe*) override; + bool sign_extend(const NetSignExtend*) override; + bool substitute(const NetSubstitute*) override; - bool process(const NetProcTop*); - bool process(const NetAnalogTop*); - void scope(const NetScope*); - void convert_module_ports(const NetScope*); - void signal(const NetNet*); - bool signal_paths(const NetNet*); + bool process(const NetProcTop*) override; + bool process(const NetAnalogTop*) override; + void scope(const NetScope*) override; + void convert_module_ports(const NetScope*) override; + void signal(const NetNet*) override; + bool signal_paths(const NetNet*) override; ivl_dll_t dll_; ivl_design_s des_; @@ -109,59 +109,59 @@ struct dll_target : public target_t, public expr_scan_t { /* These methods and members are used for forming the statements of a thread. */ struct ivl_statement_s*stmt_cur_; - void proc_alloc(const NetAlloc*); - bool proc_assign(const NetAssign*); - void proc_assign_nb(const NetAssignNB*); - bool proc_block(const NetBlock*); - bool proc_break(const NetBreak*); - void proc_case(const NetCase*); - bool proc_cassign(const NetCAssign*); - bool proc_condit(const NetCondit*); - bool proc_continue(const NetContinue*); - bool proc_contribution(const NetContribution*); - bool proc_deassign(const NetDeassign*); - bool proc_delay(const NetPDelay*); - bool proc_disable(const NetDisable*); - void proc_do_while(const NetDoWhile*); - bool proc_force(const NetForce*); - void proc_forever(const NetForever*); - bool proc_forloop(const NetForLoop*); - void proc_free(const NetFree*); - bool proc_release(const NetRelease*); - void proc_repeat(const NetRepeat*); - void proc_stask(const NetSTask*); - bool proc_trigger(const NetEvTrig*); - bool proc_nb_trigger(const NetEvNBTrig*); - void proc_utask(const NetUTask*); - bool proc_wait(const NetEvWait*); - void proc_while(const NetWhile*); + void proc_alloc(const NetAlloc*) override; + bool proc_assign(const NetAssign*) override; + void proc_assign_nb(const NetAssignNB*) override; + bool proc_block(const NetBlock*) override; + bool proc_break(const NetBreak*) override; + void proc_case(const NetCase*) override; + bool proc_cassign(const NetCAssign*) override; + bool proc_condit(const NetCondit*) override; + bool proc_continue(const NetContinue*) override; + bool proc_contribution(const NetContribution*) override; + bool proc_deassign(const NetDeassign*) override; + bool proc_delay(const NetPDelay*) override; + bool proc_disable(const NetDisable*) override; + void proc_do_while(const NetDoWhile*) override; + bool proc_force(const NetForce*) override; + void proc_forever(const NetForever*) override; + bool proc_forloop(const NetForLoop*) override; + void proc_free(const NetFree*) override; + bool proc_release(const NetRelease*) override; + void proc_repeat(const NetRepeat*) override; + void proc_stask(const NetSTask*) override; + bool proc_trigger(const NetEvTrig*) override; + bool proc_nb_trigger(const NetEvNBTrig*) override; + void proc_utask(const NetUTask*) override; + bool proc_wait(const NetEvWait*) override; + void proc_while(const NetWhile*) override; - bool func_def(const NetScope*); - void task_def(const NetScope*); + bool func_def(const NetScope*) override; + void task_def(const NetScope*) override; struct ivl_expr_s*expr_; - void expr_access_func(const NetEAccess*); - void expr_array_pattern(const NetEArrayPattern*); - void expr_binary(const NetEBinary*); - void expr_concat(const NetEConcat*); - void expr_const(const NetEConst*); - void expr_creal(const NetECReal*); - void expr_last(const NetELast*); - void expr_new(const NetENew*); - void expr_null(const NetENull*); - void expr_param(const NetEConstParam*); - void expr_property(const NetEProperty*); - void expr_rparam(const NetECRealParam*); - void expr_event(const NetEEvent*); - void expr_scope(const NetEScope*); - void expr_scopy(const NetEShallowCopy*); - void expr_netenum(const NetENetenum*); - void expr_select(const NetESelect*); - void expr_sfunc(const NetESFunc*); - void expr_ternary(const NetETernary*); - void expr_ufunc(const NetEUFunc*); - void expr_unary(const NetEUnary*); - void expr_signal(const NetESignal*); + void expr_access_func(const NetEAccess*) override; + void expr_array_pattern(const NetEArrayPattern*) override; + void expr_binary(const NetEBinary*) override; + void expr_concat(const NetEConcat*) override; + void expr_const(const NetEConst*) override; + void expr_creal(const NetECReal*) override; + void expr_last(const NetELast*) override; + void expr_new(const NetENew*) override; + void expr_null(const NetENull*) override; + void expr_param(const NetEConstParam*) override; + void expr_property(const NetEProperty*) override; + void expr_rparam(const NetECRealParam*) override; + void expr_event(const NetEEvent*) override; + void expr_scope(const NetEScope*) override; + void expr_scopy(const NetEShallowCopy*) override; + void expr_netenum(const NetENetenum*) override; + void expr_select(const NetESelect*) override; + void expr_sfunc(const NetESFunc*) override; + void expr_ternary(const NetETernary*) override; + void expr_ufunc(const NetEUFunc*) override; + void expr_unary(const NetEUnary*) override; + void expr_signal(const NetESignal*) override; ivl_scope_t lookup_scope_(const NetScope*scope); diff --git a/tgt-stub/cppcheck.sup b/tgt-stub/cppcheck.sup index 70b13cdf1..aca6f0bde 100644 --- a/tgt-stub/cppcheck.sup +++ b/tgt-stub/cppcheck.sup @@ -1,3 +1,9 @@ +// We use guarded memory allocation routines, but cppcheck is not +// noticing this so it is complaining we could return a NULL value. +nullPointerOutOfMemory:stub.c:70 // calloc @ 69 +nullPointerOutOfMemory:stub.c:71 // calloc @ 69 +nullPointerOutOfMemory:stub.c:79 // calloc @ 78 + // These are the global access functions called from the compiler so they // are not used here. diff --git a/tgt-verilog/Makefile.in b/tgt-verilog/Makefile.in index 0a04a6f47..94029b9b9 100644 --- a/tgt-verilog/Makefile.in +++ b/tgt-verilog/Makefile.in @@ -56,6 +56,8 @@ distclean: clean cppcheck: $(O:.o=.c) cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/../cppcheck-global.sup \ --suppressions-list=$(srcdir)/cppcheck.sup \ --relative-paths=$(srcdir) $(INCLUDE_PATH) $^ diff --git a/tgt-vlog95/cppcheck.sup b/tgt-vlog95/cppcheck.sup index 956fbb96a..b01687eab 100644 --- a/tgt-vlog95/cppcheck.sup +++ b/tgt-vlog95/cppcheck.sup @@ -1,3 +1,28 @@ +// We use guarded memory allocation routines, but cppcheck is not +// noticing this so it is complaining we could return a NULL value. +nullPointerOutOfMemory:logic_lpm.c:2143 // strdup @ 2140 +nullPointerOutOfMemory:logic_lpm.c:2247 // strdup @ 2244 +nullPointerOutOfMemory:misc.c:39 // malloc @ 38 +nullPointerOutOfMemory:misc.c:794 // malloc @ 793 +nullPointerOutOfMemory:misc.c:795 // malloc @ 793 +nullPointerOutOfMemory:numbers.c:351 // strdup @ 348 +nullPointerOutOfMemory:scope.c:301 // malloc @ 300 +nullPointerOutOfMemory:scope.c:302 // malloc @ 300 +nullPointerOutOfMemory:scope.c:303 // malloc @ 300 +nullPointerOutOfMemory:scope.c:304 // malloc @ 300 +nullPointerOutOfMemory:scope.c:305 // malloc @ 300 +nullPointerOutOfMemory:scope.c:307 // malloc @ 300 +nullPointerOutOfMemory:scope.c:993 // malloc @ 990 +nullPointerOutOfMemory:scope.c:994 // malloc @ 990 +nullPointerOutOfMemory:scope.c:995 // malloc @ 990 +nullPointerOutOfMemory:scope.c:996 // malloc @ 990 +nullPointerOutOfMemory:stmt.c:777 // malloc @ 775 +nullPointerOutOfMemory:stmt.c:778 // malloc @ 775 +memleakOnRealloc:scope.c:175 +memleakOnRealloc:scope.c:1021 +memleakOnRealloc:scope.c:1067 +memleakOnRealloc:udp.c:245 + // These are the global access functions called from the compiler so they // are not used here. diff --git a/tgt-vvp/cppcheck.sup b/tgt-vvp/cppcheck.sup index efd39acf9..0382fec5d 100644 --- a/tgt-vvp/cppcheck.sup +++ b/tgt-vvp/cppcheck.sup @@ -1,3 +1,55 @@ +// We use guarded memory allocation routines, but cppcheck is not +// noticing this so it is complaining we could return a NULL value. +nullPointerOutOfMemory:vvp.c:90 // malloc @ 89 +nullPointerOutOfMemory:vvp.c:91 // malloc @ 89 +nullPointerOutOfMemory:vvp.c:92 // malloc @ 89 +nullPointerOutOfMemory:draw_mux.c:83 // strdup @ 80 +nullPointerOutOfMemory:draw_mux.c:95 // strdup @ 80 +nullPointerOutOfMemory:draw_mux.c:110 // strdup @ 80 +nullPointerOutOfMemory:draw_net_input.c:92 // malloc @ 90 +nullPointerOutOfMemory:draw_net_input.c:93 // malloc @ 90 +nullPointerOutOfMemory:draw_net_input.c:118 // malloc @ 110 +nullPointerOutOfMemory:draw_net_input.c:119 // malloc @ 110 +nullPointerOutOfMemory:draw_net_input.c:237 // malloc @ 235 +nullPointerOutOfMemory:draw_net_input.c:238 // malloc @ 235 +nullPointerOutOfMemory:draw_net_input.c:256 // malloc @ 248 +nullPointerOutOfMemory:draw_net_input.c:257 // malloc @ 248 +nullPointerOutOfMemory:draw_net_input.c:269 // malloc @ 235 +nullPointerOutOfMemory:draw_net_input.c:667 // malloc @ 665 +nullPointerOutOfMemory:draw_net_input.c:668 // malloc @ 665 +nullPointerOutOfMemory:draw_net_input.c:779 // malloc @ 761 +nullPointerOutOfMemory:draw_net_input.c:780 // malloc @ 761 +nullPointerOutOfMemory:modpath.c:75 // calloc @ 68 +nullPointerOutOfMemory:modpath.c:92 // calloc @ 68 +nullPointerOutOfMemory:modpath.c:111 // calloc @ 69 +nullPointerOutOfMemory:modpath.c:139 // calloc @ 138 +nullPointerOutOfMemory:modpath.c:140 // calloc @ 138 +nullPointerOutOfMemory:modpath.c:141 // calloc @ 138 +nullPointerOutOfMemory:modpath.c:142 // calloc @ 138 +nullPointerOutOfMemory:vvp_process.c:2120 // malloc @ 2118 +nullPointerOutOfMemory:vvp_process.c:2121 // malloc @ 2118 +nullPointerOutOfMemory:vvp_scope.c:900 // calloc @ 865 +nullPointerOutOfMemory:vvp_scope.c:1094 // calloc @ 1092 +nullPointerOutOfMemory:vvp_scope.c:1117 // calloc @ 1092 +nullPointerOutOfMemory:vvp_scope.c:1700 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1701 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1730 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1731 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1741 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1745 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1746 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1757 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1764 // malloc @ 1684 +nullPointerOutOfMemory:vvp_scope.c:1991 // calloc @ 1989 +nullPointerOutOfMemory:vvp_scope.c:2062 // calloc @ 2060 +nullPointerOutOfMemory:vvp_scope.c:2077 // calloc @ 2060 +nullPointerArithmeticOutOfMemory:stmt_assign.c:216 // calloc @ 619 +nullPointerArithmeticOutOfMemory:stmt_assign.c:364 // calloc @ 619 +memleakOnRealloc:draw_net_input.c:639 +memleakOnRealloc:vvp_scope.c:57 +memleakOnRealloc:vvp_scope.c:106 +memleakOnRealloc:vvp_scope.c:853 + // These are the global access functions called from the compiler so they // are not used here. diff --git a/veriuser.h b/veriuser.h index beef27698..8187bc8d0 100644 --- a/veriuser.h +++ b/veriuser.h @@ -1,7 +1,7 @@ #ifndef VERIUSER_H #define VERIUSER_H /* - * Copyright (c) 2002-2019 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -251,7 +251,7 @@ typedef struct t_tfexprinfo { /* Extern functions from the library. */ extern void io_printf (const char *, ...) __attribute__((format (printf,1,2))); -extern char* mc_scan_plusargs(char*plusarg); +extern char* mc_scan_plusargs(const char*plusarg); extern int tf_asynchoff(void); extern int tf_asynchon(void); diff --git a/vvp/Makefile.in b/vvp/Makefile.in index a57cb0573..dba4017a3 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -110,6 +110,8 @@ distclean: clean cppcheck: $(O:.o=.cc) draw_tt.c cppcheck --enable=all --std=c99 --std=c++11 -f \ + --check-level=exhaustive \ + --suppressions-list=$(srcdir)/../cppcheck-global.sup \ --suppressions-list=$(srcdir)/cppcheck.sup \ -UMODULE_DIR1 -UMODULE_DIR2 -UYY_USER_INIT \ -UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \ diff --git a/vvp/cppcheck.sup b/vvp/cppcheck.sup index bed9bbe5a..1e449b458 100644 --- a/vvp/cppcheck.sup +++ b/vvp/cppcheck.sup @@ -1,3 +1,32 @@ +// We use guarded memory allocation routines, but cppcheck is not +// noticing this so it is complaining we could return a NULL value. +nullPointerOutOfMemory:delay.cc:829 // calloc @ 828 +nullPointerOutOfMemory:delay.cc:1252 // calloc @ 1251 +nullPointerOutOfMemory:delay.cc:1253 // calloc @ 1251 +nullPointerOutOfMemory:vpi_scope.cc:760 // calloc @ 757 +nullPointerOutOfMemory:vpi_mcd.cc:68 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:69 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:75 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:76 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:77 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:78 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:79 // malloc @ 66 +nullPointerOutOfMemory:vpi_mcd.cc:80 // malloc @ 66 +nullPointerOutOfMemory:vpi_priv.cc:1090 // malloc @ 1089 +nullPointerOutOfMemory:vpi_priv.cc:1102 // malloc @ 1101 +nullPointerOutOfMemory:vpi_priv.cc:1112 // malloc @ 1111 +nullPointerOutOfMemory:vpi_signal.cc:105 // strdup @ 623 +nullPointerOutOfMemory:vpi_signal.cc:110 // strdup @ 109 +nullPointerOutOfMemory:vpi_signal.cc:1380 // malloc @ 1379 +nullPointerOutOfMemory:vpi_tasks.cc:577 // malloc @ 574 +nullPointerOutOfMemory:vpi_tasks.cc:580 // malloc @ 574 +ctunullpointerOutOfMemory:compile.cc:651 // strdup @ 1599 (vpi_signal.cc) +ctunullpointerOutOfMemory:stop.cc:489 // strdup @ 543 +ctunullpointerOutOfMemory:vpi_signal.cc:105 // strdup @ 122 (vpi_bit.cc) +memleakOnRealloc:vpi_modules.cc:254 +memleakOnRealloc:vpi_mcd.cc:316 +memleakOnRealloc:vpi_signal.cc:1205 + // The new() operator is always used to allocate space for this class and // pool is defined there. uninitMemberVar:vvp_net.cc:192 @@ -57,3 +86,32 @@ unusedFunction:lib_main.cc:71 unusedFunction:lib_main.cc:62 // vvp_set_verbose_flag() unusedFunction:lib_main.cc:76 + +// The following are just unused. +// alias_word() +unusedFunction:array.cc:848 +// intermodpath_delete() +unusedFunction:delay.cc:1462 +// count_force4_pool() +unusedFunction:schedule.cc:402 +// call_scope() +unusedFunction:ufunc.h:62 +// get_bit() +unusedFunction:vpi_priv.h:477 +// copy_bits() +unusedFunction:vvp_net.cc:615 +// mov() +unusedFunction:vvp_net.cc:1546 +// eq_xz() +unusedFunction:vvp_net.cc:1751 +// as_string() +unusedFunction:vvp_net.cc:1854 +// fully_featured_resolv_() +unusedFunction:vvp_net.cc:3582 +// words() +unusedFunction:vvp_net.h:595 +// force_vec8() +unusedFunction:vvp_net_sig.cc:128 + +// Unused functions from the lexor +unusedFunction:lexor.cc diff --git a/vvp/delay.cc b/vvp/delay.cc index f52101f9c..1b9881094 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -166,7 +166,7 @@ vvp_fun_delay::vvp_fun_delay(vvp_net_t*n, unsigned width, const vvp_delay_t&d) initial_ = true; // Calculate the values used when converting variable delays // to simulation time units. - __vpiScope*scope = vpip_peek_current_scope(); + const __vpiScope*scope = vpip_peek_current_scope(); int powr = scope->time_units - scope->time_precision; round_ = 1; @@ -820,12 +820,12 @@ static vpiHandle modpath_src_iterate(int code, vpiHandle ref) // ever one input path term and one output path term. switch (code) { case vpiModPathIn: { - vpiHandle*args = (vpiHandle*)calloc(1, sizeof(vpiHandle*)); + vpiHandle*args = static_cast(calloc(1, sizeof(vpiHandle*))); args[0] = &rfp->path_term_in; return vpip_make_iterator(1, args, true); } case vpiModPathOut: { - vpiHandle*args = (vpiHandle*)calloc(1, sizeof(vpiHandle*)); + vpiHandle*args = static_cast(calloc(1, sizeof(vpiHandle*))); args[0] = &rfp->dest->path_term_out; return vpip_make_iterator(1, args, true); } @@ -1081,8 +1081,9 @@ struct __vpiModPath* vpip_make_modpath(vvp_net_t *net) #ifdef CHECK_WITH_VALGRIND mp_count += 1; - mp_list = (struct __vpiModPath **) realloc(mp_list, - mp_count*sizeof(struct __vpiModPath **)); + mp_list = static_cast + (realloc(static_cast(mp_list), + mp_count*sizeof(struct __vpiModPath **))); mp_list[mp_count-1] = obj; #endif return obj; @@ -1247,7 +1248,7 @@ static vpiHandle intermodpath_iterate(int code, vpiHandle ref) // For now intermodpaths only support exactly two ports switch (code) { case vpiPort: { - vpiHandle*args = (vpiHandle*)calloc(2, sizeof(vpiHandle*)); + vpiHandle*args = static_cast(calloc(2, sizeof(vpiHandle*))); args[0] = rfp->port1; args[1] = rfp->port2; return vpip_make_iterator(2, args, true); @@ -1449,8 +1450,9 @@ struct __vpiInterModPath* vpip_make_intermodpath(vvp_net_t *net, vpiPortInfo* po #ifdef CHECK_WITH_VALGRIND imp_count += 1; - imp_list = (struct __vpiInterModPath **) realloc(imp_list, - imp_count*sizeof(struct __vpiInterModPath **)); + imp_list = static_cast + (realloc(static_cast(imp_list), + imp_count*sizeof(struct __vpiInterModPath **))); imp_list[imp_count-1] = obj; #endif return obj; diff --git a/vvp/event.cc b/vvp/event.cc index dac482983..e34064dac 100644 --- a/vvp/event.cc +++ b/vvp/event.cc @@ -370,7 +370,7 @@ class anyedge_vec4_value : public anyedge_value { public: anyedge_vec4_value() {}; - virtual ~anyedge_vec4_value() {}; + virtual ~anyedge_vec4_value() override {}; void reset() override { old_bits.set_to_x(); } @@ -402,7 +402,7 @@ class anyedge_real_value : public anyedge_value { public: anyedge_real_value() : old_bits(0.0) {}; - virtual ~anyedge_real_value() {}; + virtual ~anyedge_real_value() override {}; void reset() override { old_bits = 0.0; } @@ -431,7 +431,7 @@ class anyedge_string_value : public anyedge_value { public: anyedge_string_value() {}; - virtual ~anyedge_string_value() {}; + virtual ~anyedge_string_value() override {}; void reset() override { old_bits.clear(); } diff --git a/vvp/vpi_bit.cc b/vvp/vpi_bit.cc index fe5623d6a..ad76f9a22 100644 --- a/vvp/vpi_bit.cc +++ b/vvp/vpi_bit.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Cary R. (cygcary@yahoo.com) + * Copyright (C) 2020-2025 Cary R. (cygcary@yahoo.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -32,15 +32,15 @@ static const __vpiBit*bit_from_handle(const __vpiHandle*ref) if (ref == NULL) return NULL; const __vpiBit::as_bit_t*ptr = dynamic_cast (ref); if (ptr == NULL) return NULL; - return (const struct __vpiBit*) ref; + return reinterpret_cast(ref); } static __vpiBit*bit_from_handle(__vpiHandle*ref) { if (ref == NULL) return NULL; - __vpiBit::as_bit_t*ptr = dynamic_cast<__vpiBit::as_bit_t*> (ref); + const __vpiBit::as_bit_t*ptr = dynamic_cast<__vpiBit::as_bit_t*> (ref); if (ptr == NULL) return NULL; - return (struct __vpiBit*) ref; + return reinterpret_cast(ref); } static int bit_get_type(const __vpiBit*rfp) @@ -118,7 +118,8 @@ static char* bit_get_str(int code, vpiHandle ref) struct __vpiSignal*parent = rfp->get_parent(); assert(parent); - char *nm, *ixs; + char *nm; + const char *ixs; nm = strdup(vpi_get_str(vpiName, parent)); s_vpi_value vp; vp.format = vpiDecStrVal; diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index e0d2e2c43..f779027a6 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -174,7 +174,7 @@ struct sync_cb : public vvp_gen_event_s { sync_callback*handle; bool sync_flag; - ~sync_cb () { } + ~sync_cb () override { } virtual void run_run() override; }; @@ -231,7 +231,7 @@ static void vpip_real_value_change(value_callback*cbh, vpiHandle ref) class value_part_callback : public value_callback { public: explicit value_part_callback(p_cb_data data); - ~value_part_callback(); + ~value_part_callback() override; bool test_value_callback_ready(void) override; @@ -398,7 +398,7 @@ static value_callback* make_value_change(p_cb_data data) class sync_callback : public __vpiCallback { public: explicit sync_callback(p_cb_data data); - ~sync_callback(); + ~sync_callback() override; public: // scheduled event @@ -969,7 +969,7 @@ static uint64_t vlg_round_to_u64(double rval) static void real_signal_value(struct t_vpi_value*vp, double rval) { static const size_t RBUF_SIZE = 64 + 1; - char*rbuf = (char *) need_result_buf(RBUF_SIZE, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(RBUF_SIZE, RBUF_VAL)); switch (vp->format) { case vpiObjTypeVal: diff --git a/vvp/vpi_cobject.cc b/vvp/vpi_cobject.cc index d0343e3d2..72f395301 100644 --- a/vvp/vpi_cobject.cc +++ b/vvp/vpi_cobject.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2022 Picture Elements, Inc. + * Copyright (c) 2012-2025 Picture Elements, Inc. * Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -69,7 +69,7 @@ void __vpiCobjectVar::vpi_get_value(p_vpi_value val) // FIXME: We need to get the assigned object address if one is assigned. //fprintf(stderr, "HERE: %p\n", get_net()); static const size_t RBUF_USE_SIZE = 64 + 1; - char*rbuf = (char *) need_result_buf(RBUF_USE_SIZE, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(RBUF_USE_SIZE, RBUF_VAL)); switch (val->format) { case vpiObjTypeVal: @@ -93,9 +93,9 @@ void __vpiCobjectVar::vpi_get_value(p_vpi_value val) break; case vpiVectorVal: - val->value.vector = (p_vpi_vecval) - need_result_buf(2*sizeof(s_vpi_vecval), - RBUF_VAL); + val->value.vector = static_cast + (need_result_buf(2*sizeof(s_vpi_vecval), + RBUF_VAL)); for (unsigned idx = 0; idx < 2; idx += 1) { val->value.vector[idx].aval = 0; val->value.vector[idx].bval = 0; diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index 72ab9c0b3..bdb4a6f97 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -32,7 +32,7 @@ class __vpiStringConst : public __vpiHandle { public: explicit __vpiStringConst(char*val); - ~__vpiStringConst(); + ~__vpiStringConst() override; int get_type_code(void) const override; int vpi_get(int code) override; void vpi_get_value(p_vpi_value val) override; @@ -132,7 +132,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp) // fallthrough case vpiStringVal: cp = value_; - rbuf = (char *) need_result_buf(size + 1, RBUF_VAL); + rbuf = static_cast(need_result_buf(size + 1, RBUF_VAL)); vp->value.str = rbuf; for (unsigned int i = 0; i < size; i++) { @@ -163,7 +163,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp) "at first 4 bytes!\n"); } static const size_t RBUF_USE_SIZE = 12; - rbuf = (char *) need_result_buf(RBUF_USE_SIZE, RBUF_VAL); + rbuf = static_cast(need_result_buf(RBUF_USE_SIZE, RBUF_VAL)); uint_value = 0; for(unsigned i=0; i(need_result_buf(8 * size + 1, RBUF_VAL)); cp = rbuf; for(unsigned i=0; i=0; bit -= 1){ @@ -186,7 +186,7 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp) break; case vpiHexStrVal: - rbuf = (char *) need_result_buf(2 * size + 1, RBUF_VAL); + rbuf = static_cast(need_result_buf(2 * size + 1, RBUF_VAL)); cp = rbuf; for(unsigned i=0; i=0; nibble -= 1){ @@ -213,10 +213,10 @@ void __vpiStringConst::vpi_get_value(p_vpi_value vp) break; case vpiVectorVal: - vp->value.vector = (p_vpi_vecval) - need_result_buf((size+3)/4* - sizeof(s_vpi_vecval), - RBUF_VAL); + vp->value.vector = static_cast + (need_result_buf((size+3)/4* + sizeof(s_vpi_vecval), + RBUF_VAL)); uint_value = 0; vecp = vp->value.vector; vecp->aval = vecp->bval = 0; @@ -271,7 +271,7 @@ vpiHandle vpip_make_string_const(char*text, bool persistent_flag) class __vpiStringParam : public __vpiStringConst { public: __vpiStringParam(char*txt, char*name); - ~__vpiStringParam(); + ~__vpiStringParam() override; int get_type_code(void) const override; int vpi_get(int code) override; char*vpi_get_str(int code) override; @@ -465,7 +465,7 @@ vvp_vector4_t vector4_from_text(const char*bits, unsigned wid) struct __vpiBinaryParam : public __vpiBinaryConst { __vpiBinaryParam(const vvp_vector4_t&b, char*name); - ~__vpiBinaryParam(); + ~__vpiBinaryParam() override; int get_type_code(void) const override; int vpi_get(int code) override; char*vpi_get_str(int code) override; @@ -595,7 +595,7 @@ int __vpiDecConst::vpi_get(int code) void __vpiDecConst::vpi_get_value(p_vpi_value vp) { static const size_t RBUF_USE_SIZE = 64 + 1; - char*rbuf = (char *) need_result_buf(RBUF_USE_SIZE, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(RBUF_USE_SIZE, RBUF_VAL)); char*cp = rbuf; switch (vp->format) { @@ -613,7 +613,7 @@ void __vpiDecConst::vpi_get_value(p_vpi_value vp) case vpiBinStrVal: for(int bit=31; bit>=0;bit--){ - *cp++ = "01"[ (value>>bit)&1 ]; + *cp++ = "01"[ (static_cast(value)>>bit)&1 ]; } *cp = 0; @@ -692,7 +692,7 @@ vpiHandle vpip_make_real_const(double value) struct __vpiRealParam : public __vpiRealConst { __vpiRealParam(double val, char*name); - ~__vpiRealParam(); + ~__vpiRealParam() override; int get_type_code(void) const override; int vpi_get(int code) override; char*vpi_get_str(int code) override; @@ -815,7 +815,7 @@ int __vpiNullConst::vpi_get(int code) void __vpiNullConst::vpi_get_value(p_vpi_value val) { static const size_t RBUF_USE_SIZE = 64 + 1; - char*rbuf = (char *) need_result_buf(RBUF_USE_SIZE, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(RBUF_USE_SIZE, RBUF_VAL)); switch (val->format) { @@ -840,9 +840,9 @@ void __vpiNullConst::vpi_get_value(p_vpi_value val) break; case vpiVectorVal: - val->value.vector = (p_vpi_vecval) - need_result_buf(2*sizeof(s_vpi_vecval), - RBUF_VAL); + val->value.vector = static_cast + (need_result_buf(2*sizeof(s_vpi_vecval), + RBUF_VAL)); for (unsigned idx = 0; idx < 2; idx += 1) { val->value.vector[idx].aval = 0; val->value.vector[idx].bval = 0; diff --git a/vvp/vpi_darray.cc b/vvp/vpi_darray.cc index 6edde31d0..d871f9bc3 100644 --- a/vvp/vpi_darray.cc +++ b/vvp/vpi_darray.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2022 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -42,12 +42,12 @@ __vpiDarrayVar::__vpiDarrayVar(__vpiScope*sc, const char*na, vvp_net_t*ne) unsigned __vpiDarrayVar::get_size() const { - vvp_fun_signal_object*fun = dynamic_cast (get_net()->fun); + const vvp_fun_signal_object*fun = dynamic_cast (get_net()->fun); if(!fun) return 0; vvp_object_t val = fun->get_object(); - vvp_darray*aval = val.peek(); + const vvp_darray*aval = val.peek(); if(!aval) return 0; @@ -307,7 +307,7 @@ int __vpiQueueVar::vpi_get(int code) vvp_fun_signal_object*fun = dynamic_cast (get_net()->fun); assert(fun); vvp_object_t val = fun->get_object(); - vvp_queue*aval = val.peek(); + const vvp_queue*aval = val.peek(); switch (code) { case vpiArrayType: diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 93d3e29c3..9f723108b 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2024 Stephen G. Tell + * Copyright (c) 2000-2025 Stephen G. Tell * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -41,7 +41,7 @@ extern FILE* vpi_trace; /* * MCD/FD manipulation macros */ -#define IS_MCD(mcd) !((mcd)>>31&1) +#define IS_MCD(mcd) !(static_cast(mcd)>>31&1) #define FD_IDX(fd) ((fd)&~(1U<<31)) #define FD_INCR 32 @@ -63,7 +63,7 @@ bool vpip_mcd0_disable = false; void vpip_mcd_init(FILE *log) { fd_table_len = FD_INCR; - fd_table = (mcd_entry_s *) malloc(fd_table_len*sizeof(mcd_entry_s)); + fd_table = static_cast(malloc(fd_table_len*sizeof(mcd_entry_s))); for (unsigned idx = 0; idx < fd_table_len; idx += 1) { fd_table[idx].fp = NULL; fd_table[idx].filename = NULL; @@ -210,7 +210,7 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap) * so the print needs to be redone with a larger buffer (very rare). */ if ((unsigned) rc >= sizeof buffer) { - buf_ptr = (char *)malloc(rc + 1); + buf_ptr = static_cast(malloc(rc + 1)); need_free = true; rc = vsnprintf(buf_ptr, rc+1, fmt, saved_ap); } @@ -313,8 +313,8 @@ extern "C" PLI_INT32 vpi_fopen(const char*name, const char*mode) return 0; } fd_table_len += FD_INCR; - fd_table = (mcd_entry_s *) realloc(fd_table, - fd_table_len*sizeof(mcd_entry_s)); + fd_table = static_cast + (realloc(fd_table, fd_table_len*sizeof(mcd_entry_s))); for (unsigned idx = i; idx < fd_table_len; idx += 1) { fd_table[idx].fp = NULL; fd_table[idx].filename = NULL; diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 6c96ad7d3..d6dd3a2f2 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2022 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -72,7 +72,7 @@ void vpip_add_env_and_default_module_paths() if (char *var = ::getenv("IVERILOG_VPI_MODULE_PATH")) { char *ptr = var; - char *end = var+strlen(var); + const char *end = var+strlen(var); int len = 0; while (ptr <= end) { if (*ptr == 0 || *ptr == path_sep) { @@ -232,7 +232,7 @@ void vpip_load_module(const char*name) #if defined(__MINGW32__) || defined (__CYGWIN__) void*function = ivl_dlsym(dll, "vpip_set_callback"); if (function) { - vpip_set_callback_t set_callback = (vpip_set_callback_t)function; + vpip_set_callback_t set_callback = static_cast(function); if (!set_callback(&vpi_routines, vpip_routines_version)) { fprintf(stderr, "Failed to link VPI module %s. Try rebuilding it with iverilog-vpi.\n", name); ivl_dlclose(dll); @@ -250,7 +250,8 @@ void vpip_load_module(const char*name) /* Add the dll to the list so it can be closed when we are done. */ dll_list_cnt += 1; - dll_list = (ivl_dll_t*)realloc(dll_list, dll_list_cnt*sizeof(ivl_dll_t)); + dll_list = static_cast + (realloc(static_cast(dll_list), dll_list_cnt*sizeof(ivl_dll_t))); dll_list[dll_list_cnt-1] = dll; vpi_mode_flag = VPI_MODE_REGISTER; diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 5f8aed750..81327cfc2 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -223,7 +223,7 @@ PLI_INT32 vpi_chk_error(p_vpi_error_info info) info->level = vpip_last_error.level; info->message = vpip_last_error.message; info->product = vpi_vlog_info.product; - info->code = (char *) ""; + info->code = (char *)""; info->file = 0; info->line = 0; @@ -500,7 +500,7 @@ __vpiScope*vpip_timescale_scope_from_handle(vpiHandle obj) struct __vpiSysTaskCall*task; struct __vpiSignal*signal; struct __vpiRealVar*real; - __vpiNamedEvent*event; + const __vpiNamedEvent*event; switch (obj->get_type_code()) { case vpiSysTaskCall: @@ -547,7 +547,7 @@ int vpip_time_units_from_handle(vpiHandle obj) if (obj == 0) return vpip_get_time_precision(); - __vpiScope*scope = vpip_timescale_scope_from_handle(obj); + const __vpiScope*scope = vpip_timescale_scope_from_handle(obj); if (scope == 0) return vpip_get_time_precision(); @@ -559,7 +559,7 @@ int vpip_time_precision_from_handle(vpiHandle obj) if (obj == 0) return vpip_get_time_precision(); - __vpiScope*scope = vpip_timescale_scope_from_handle(obj); + const __vpiScope*scope = vpip_timescale_scope_from_handle(obj); if (scope == 0) return vpip_get_time_precision(); @@ -641,7 +641,7 @@ static void vec4_get_value_string(const vvp_vector4_t&word_val, unsigned width, unsigned nchar = width / 8; unsigned tail = width % 8; - char*rbuf = (char *) need_result_buf(nchar + 1, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(nchar + 1, RBUF_VAL)); char*cp = rbuf; if (tail > 0) { @@ -700,7 +700,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, break; case vpiBinStrVal: - rbuf = (char *) need_result_buf(width+1, RBUF_VAL); + rbuf = static_cast(need_result_buf(width+1, RBUF_VAL)); for (unsigned idx = 0 ; idx < width ; idx += 1) { vvp_bit4_t bit = word_val.value(idx); rbuf[width-idx-1] = vvp_bit4_to_ascii(bit); @@ -711,7 +711,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, case vpiOctStrVal: { unsigned hwid = ((width+2) / 3) + 1; - rbuf = (char *) need_result_buf(hwid, RBUF_VAL); + rbuf = static_cast(need_result_buf(hwid, RBUF_VAL)); vpip_vec4_to_oct_str(word_val, rbuf, hwid); vp->value.str = rbuf; break; @@ -719,7 +719,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, case vpiDecStrVal: { // HERE need a better estimate. - rbuf = (char *) need_result_buf(width+1, RBUF_VAL); + rbuf = static_cast(need_result_buf(width+1, RBUF_VAL)); vpip_vec4_to_dec_str(word_val, rbuf, width+1, signed_flag); vp->value.str = rbuf; break; @@ -727,7 +727,7 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, case vpiHexStrVal: { unsigned hwid = ((width + 3) / 4) + 1; - rbuf = (char *) need_result_buf(hwid, RBUF_VAL); + rbuf = static_cast(need_result_buf(hwid, RBUF_VAL)); vpip_vec4_to_hex_str(word_val, rbuf, hwid); vp->value.str = rbuf; break; @@ -778,8 +778,8 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width, case vpiVectorVal: { unsigned hwid = (width + 31)/32; - s_vpi_vecval *op = (p_vpi_vecval) - need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL); + s_vpi_vecval *op = static_cast + (need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL)); vp->value.vector = op; op->aval = op->bval = 0; @@ -842,8 +842,8 @@ void vpip_vec2_get_value(const vvp_vector2_t&word_val, unsigned width, case vpiVectorVal: { unsigned hwid = (width + 31)/32; - s_vpi_vecval *op = (p_vpi_vecval) - need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL); + s_vpi_vecval *op = static_cast + (need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL)); vp->value.vector = op; op->aval = op->bval = 0; @@ -923,7 +923,7 @@ void vpip_real_get_value(double real, s_vpi_value*vp) break; case vpiDecStrVal: - rbuf = (char *) need_result_buf(1025, RBUF_VAL); + rbuf = static_cast(need_result_buf(1025, RBUF_VAL)); vpip_vec4_to_dec_str(vvp_vector4_t(1024, real), rbuf, 1025, true); vp->value.str = rbuf; break; @@ -997,7 +997,7 @@ void vpip_string_get_value(const string&val, s_vpi_value*vp) vp->format = vpiStringVal; // fallthrough case vpiStringVal: - rbuf = (char *) need_result_buf(val.size() + 1, RBUF_VAL); + rbuf = static_cast(need_result_buf(val.size() + 1, RBUF_VAL)); strcpy(rbuf, val.c_str()); vp->value.str = rbuf; break; @@ -1049,7 +1049,7 @@ struct vpip_put_value_event : vvp_gen_event_s { s_vpi_value value; int flags; virtual void run_run() override; - ~vpip_put_value_event() { } + ~vpip_put_value_event() override { } }; void vpip_put_value_event::run_run() @@ -1350,7 +1350,7 @@ static vpiHandle find_name(const char *name, vpiHandle handle) * name it cannot be found by name. Because of this we need * to skip ports here so the correct handle can be located. */ if (vpi_get(vpiType, ref->intern[i]) == vpiPort) continue; - char *nm = vpi_get_str(vpiName, ref->intern[i]); + const char *nm = vpi_get_str(vpiName, ref->intern[i]); if (nm && !strcmp(name, nm)) { rtn = ref->intern[i]; break; @@ -1418,7 +1418,7 @@ static vpiHandle find_scope(const char *name, vpiHandle handle, int depth) vpiHandle rtn = 0; vpiHandle hand; while (iter && (hand = vpi_scan(iter))) { - char *nm = vpi_get_str(vpiName, hand); + const char *nm = vpi_get_str(vpiName, hand); if (strcmp(nm_first,nm)==0) { if (nm_rest) @@ -1727,7 +1727,7 @@ vpiHandle vpi_handle_multi(PLI_INT32 type, while (current_net) { if (!current_net) break; // End of list - vvp_fun_part* part = dynamic_cast(current_net->fun); + const vvp_fun_part* part = dynamic_cast(current_net->fun); // Its a part select! if (part) { diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index b8ab23670..3710d61f5 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -1086,8 +1086,8 @@ extern double vpip_scaled_time_from_handle(vvp_time64_t time, vpiHandle obj); extern void vpip_time_to_timestruct(struct t_vpi_time*ts, vvp_time64_t ti); extern vvp_time64_t vpip_timestruct_to_time(const struct t_vpi_time*ts); -extern double vpip_time_to_scaled_real(vvp_time64_t ti, __vpiScope*sc); -extern vvp_time64_t vpip_scaled_real_to_time64(double val, __vpiScope*sc); +extern double vpip_time_to_scaled_real(vvp_time64_t ti, const __vpiScope*sc); +extern vvp_time64_t vpip_scaled_real_to_time64(double val, const __vpiScope*sc); /* * These functions are used mostly as compile time to strings into diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index 23f63c53d..ced8c7f3d 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2022 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -61,7 +61,8 @@ static char* real_var_get_str(int code, vpiHandle ref) return simple_set_rbuf_str(file_names[0]); } - char *nm, *ixs; + char *nm; + const char *ixs; if (rfp->is_netarray) { nm = strdup(vpi_get_str(vpiName, rfp->within.parent)); s_vpi_value vp; diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index e66cda633..f06cdcc62 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -149,8 +149,9 @@ static void delete_sub_scopes(__vpiScope *scope) for (citer = scope->classes.begin(); citer != scope->classes.end(); ++ citer ) { class_list_count += 1; - class_list = (class_type **) realloc(class_list, - class_list_count*sizeof(class_type **)); + class_list = static_cast + (realloc(static_cast(class_list), + class_list_count*sizeof(class_type **))); class_list[class_list_count-1] = citer->second; } } @@ -324,7 +325,7 @@ static vpiHandle make_subset_iterator_(int type_code, vector&table) if (mcnt == 0) return 0; - args = (vpiHandle*)calloc(mcnt, sizeof(vpiHandle)); + args = static_cast(calloc(mcnt, sizeof(vpiHandle))); for (unsigned idx = 0; idx < table.size(); idx += 1) if (compare_types(type_code, table[idx]->get_type_code())) args[ncnt++] = table[idx]; @@ -658,11 +659,12 @@ unsigned vpip_add_item_to_context(automatic_hooks_s*item, unsigned idx = scope->nitem++; if (scope->item == 0) - scope->item = (automatic_hooks_s**) - malloc(sizeof(automatic_hooks_s*)); + scope->item = static_cast + (malloc(sizeof(automatic_hooks_s*))); else - scope->item = (automatic_hooks_s**) - realloc(scope->item, sizeof(automatic_hooks_s*)*scope->nitem); + scope->item = static_cast + (realloc(static_cast(scope->item), + sizeof(automatic_hooks_s*)*scope->nitem)); scope->item[idx] = item; @@ -752,7 +754,7 @@ static vpiHandle portinfo_iterate(int code, vpiHandle ref) switch (code) { case vpiBit: { - vpiHandle*args = (vpiHandle*)calloc(width, sizeof(vpiHandle*)); + vpiHandle*args = static_cast(calloc(width, sizeof(vpiHandle*))); for (unsigned i = 0; iport_bits_.size(); i++) { args[i] = rfp->port_bits_[i]; diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index f21731777..af6d9bf92 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -95,7 +95,7 @@ void *need_result_buf(unsigned cnt, vpi_rbuf_t type) char *simple_set_rbuf_str(const char *s1) { - char *res = (char *) need_result_buf(strlen(s1)+1, RBUF_STR); + char *res = static_cast(need_result_buf(strlen(s1)+1, RBUF_STR)); if (res) strcpy(res,s1); return res; } @@ -114,7 +114,7 @@ char *generic_get_str(int code, vpiHandle ref, const char *name, const char *ind } if (index != NULL) len += strlen(index) + 2; /* include space for brackets */ - char *res = (char *) need_result_buf(len, RBUF_STR); + char *res = static_cast(need_result_buf(len, RBUF_STR)); if (!res) { free(bn); return NULL; @@ -159,7 +159,7 @@ static vpiHandle fill_in_var4(struct __vpiSignal*obj, static void format_vpiBinStrVal(vvp_signal_value*sig, int base, unsigned wid, s_vpi_value*vp) { - char *rbuf = (char *) need_result_buf(wid+1, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(wid+1, RBUF_VAL)); long end = base + (signed)wid; long offset = end - 1; long ssize = (signed)sig->value_size(); @@ -180,7 +180,7 @@ static void format_vpiOctStrVal(vvp_signal_value*sig, int base, unsigned wid, s_vpi_value*vp) { unsigned dwid = (wid + 2) / 3; - char *rbuf = (char *) need_result_buf(dwid+1, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(dwid+1, RBUF_VAL)); long end = base + (signed)wid; long ssize = (signed)sig->value_size(); unsigned val = 0; @@ -236,7 +236,7 @@ static void format_vpiHexStrVal(vvp_signal_value*sig, int base, unsigned wid, s_vpi_value*vp) { unsigned dwid = (wid + 3) / 4; - char *rbuf = (char *) need_result_buf(dwid+1, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(dwid+1, RBUF_VAL)); long end = base + (signed)wid; long ssize = (signed)sig->value_size(); unsigned val = 0; @@ -296,7 +296,7 @@ static void format_vpiDecStrVal(vvp_signal_value*sig, int base, unsigned wid, int signed_flag, s_vpi_value*vp) { unsigned hwid = (sig->value_size()+2) / 3 + 1; - char *rbuf = (char *) need_result_buf(hwid, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(hwid, RBUF_VAL)); long ssize = (signed)sig->value_size(); long end = base + (signed)wid; @@ -382,7 +382,7 @@ static void format_vpiStringVal(vvp_signal_value*sig, int base, unsigned wid, /* The result will use a character for each 8 bits of the vector. Add one extra character for the highest bits that don't form an 8 bit group. */ - char *rbuf = (char *) need_result_buf(wid/8 + ((wid&7)!=0) + 1, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(wid/8 + ((wid&7)!=0) + 1, RBUF_VAL)); char *cp = rbuf; char tmp = 0; @@ -442,8 +442,8 @@ static void format_vpiStrengthVal(vvp_signal_value*sig, int base, long end = base + (signed)wid; s_vpi_strengthval*op; - op = (s_vpi_strengthval*) - need_result_buf(wid * sizeof(s_vpi_strengthval), RBUF_VAL); + op = static_cast + (need_result_buf(wid * sizeof(s_vpi_strengthval), RBUF_VAL)); for (long idx = base ; idx < end ; idx += 1) { if (idx >=0 && idx < (signed)sig->value_size()) { @@ -497,8 +497,8 @@ static void format_vpiVectorVal(vvp_signal_value*sig, int base, unsigned wid, unsigned int obit = 0; unsigned hwid = (wid + 31)/32; - s_vpi_vecval *op = (p_vpi_vecval) - need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL); + s_vpi_vecval *op = static_cast + (need_result_buf(hwid * sizeof(s_vpi_vecval), RBUF_VAL)); vp->value.vector = op; op->aval = op->bval = 0; @@ -618,7 +618,8 @@ static char* signal_get_str(int code, vpiHandle ref) if ((code != vpiName) && (code != vpiFullName)) return NULL; - char *nm, *ixs; + char *nm; + const char *ixs; if (rfp->is_netarray) { nm = strdup(vpi_get_str(vpiName, rfp->within.parent)); s_vpi_value vp; @@ -1194,16 +1195,17 @@ void* __vpiSignal::operator new(size_t siz) const unsigned alloc_count = 512; if ((alloc_array == 0) || (alloc_index == alloc_count)) { - alloc_array = (struct vpiSignal_plug*) - calloc(alloc_count, sizeof(struct vpiSignal_plug)); + alloc_array = static_cast + (calloc(alloc_count, sizeof(struct vpiSignal_plug))); alloc_index = 0; #ifdef CHECK_WITH_VALGRIND VALGRIND_MAKE_MEM_NOACCESS(alloc_array, alloc_count * sizeof(struct vpiSignal_plug)); VALGRIND_CREATE_MEMPOOL(alloc_array, 0, 1); signal_pool_count += 1; - signal_pool = (vpiSignal_plug **) realloc(signal_pool, - signal_pool_count*sizeof(vpiSignal_plug **)); + signal_pool = static_cast + (realloc(static_cast(signal_pool), + signal_pool_count*sizeof(vpiSignal_plug **))); signal_pool[signal_pool_count-1] = alloc_array; #endif } @@ -1374,7 +1376,7 @@ static char* PV_get_str(int code, vpiHandle ref) case vpiFullName: { const char*nm = vpi_get_str(code, rfp->parent); size_t len = 256+strlen(nm); - char *full = (char *) malloc(len); + char *full = static_cast(malloc(len)); snprintf(full, len, "%s[%d:%d]", nm, (int)vpi_get(vpiLeftRange, ref), (int)vpi_get(vpiRightRange, ref)); diff --git a/vvp/vpi_string.cc b/vvp/vpi_string.cc index 7ae1d95cd..eb24dd7b1 100644 --- a/vvp/vpi_string.cc +++ b/vvp/vpi_string.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2022 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -69,7 +69,7 @@ void __vpiStringVar::vpi_get_value(p_vpi_value val) string str = fun->get_string(); if (val->format == vpiStringVal || val->format == vpiObjTypeVal) { - char*rbuf = (char *) need_result_buf(str.size()+1, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(str.size()+1, RBUF_VAL)); strcpy(rbuf, str.c_str()); val->format = vpiStringVal; val->value.str = rbuf; diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index c9e64b308..3b3663aa9 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -114,7 +114,7 @@ static int sysfunc_get(int type, vpiHandle ref) static char *systask_get_str(int type, vpiHandle ref) { - struct __vpiSysTaskCall*rfp = dynamic_cast<__vpiSysTaskCall*>(ref); + const struct __vpiSysTaskCall*rfp = dynamic_cast<__vpiSysTaskCall*>(ref); switch (type) { case vpiFile: @@ -143,7 +143,7 @@ static vpiHandle systask_iter(int, vpiHandle ref) } struct systask_def : public __vpiSysTaskCall { - virtual ~systask_def() {}; + virtual ~systask_def() override {} virtual int get_type_code(void) const override { return vpiSysTaskCall; } virtual int vpi_get(int code) override { return systask_get(code, this); } virtual char*vpi_get_str(int code) override { return systask_get_str(code, this); } @@ -152,7 +152,7 @@ struct systask_def : public __vpiSysTaskCall { }; struct sysfunc_def : public systask_def { - virtual ~sysfunc_def() {}; + virtual ~sysfunc_def() override {}; virtual int get_type_code(void) const override { return vpiSysFuncCall; } virtual int vpi_get(int code) override { return sysfunc_get(code, this); } }; @@ -571,8 +571,8 @@ static unsigned def_count = 0; static struct __vpiUserSystf* allocate_def(void) { if (def_table == 0) { - def_table = (struct __vpiUserSystf**) - malloc(sizeof (struct __vpiUserSystf*)); + def_table = static_cast + (malloc(sizeof(struct __vpiUserSystf*))); def_table[0] = new __vpiUserSystf; @@ -580,8 +580,9 @@ static struct __vpiUserSystf* allocate_def(void) return def_table[0]; } - def_table = (struct __vpiUserSystf**) - realloc(def_table, (def_count+1)*sizeof (struct __vpiUserSystf*)); + def_table = static_cast + (realloc(static_cast(def_table), + (def_count+1)*sizeof(struct __vpiUserSystf*))); def_table[def_count] = new __vpiUserSystf; @@ -706,10 +707,10 @@ static unsigned vpi_call_error_num = 0; static void add_vpi_call_error(vpi_call_error_type type, const char *name, long file_idx, long lineno) { - vpi_call_error_lst = (vpi_call_error_p) - realloc((void *)vpi_call_error_lst, + vpi_call_error_lst = static_cast + (realloc(static_cast(vpi_call_error_lst), (vpi_call_error_num + 1) * - sizeof(vpi_call_error_s)); + sizeof(vpi_call_error_s))); vpi_call_error_lst[vpi_call_error_num].type = type; vpi_call_error_lst[vpi_call_error_num].name = strdup(name); vpi_call_error_lst[vpi_call_error_num].file_idx = file_idx; @@ -974,13 +975,13 @@ void vpip_execute_vpi_call(vthread_t thr, vpiHandle ref) /* If the function returns a value, then push the value to the appropriate thread stack. */ - if (sysfunc_real*func_real = dynamic_cast(ref)) { + if (const sysfunc_real*func_real = dynamic_cast(ref)) { vthread_push(thr, func_real->return_value()); } - else if (sysfunc_str*func_string = dynamic_cast(ref)) { + else if (const sysfunc_str*func_string = dynamic_cast(ref)) { vthread_push(thr, func_string->return_value()); } - else if (sysfunc_vec4*func_vec4 = dynamic_cast(ref)) { + else if (const sysfunc_vec4*func_vec4 = dynamic_cast(ref)) { vthread_push(thr, func_vec4->return_value()); } vpip_cur_task = 0; diff --git a/vvp/vpi_time.cc b/vvp/vpi_time.cc index 0c1ffc5fb..c673efa3d 100644 --- a/vvp/vpi_time.cc +++ b/vvp/vpi_time.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2018 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2025 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -53,7 +53,7 @@ vvp_time64_t vpip_timestruct_to_time(const struct t_vpi_time*ts) return ti; } -double vpip_time_to_scaled_real(vvp_time64_t ti, __vpiScope*scope) +double vpip_time_to_scaled_real(vvp_time64_t ti, const __vpiScope*scope) { double val; int scale = 0; @@ -70,7 +70,7 @@ double vpip_time_to_scaled_real(vvp_time64_t ti, __vpiScope*scope) * does not check for overflow. It is only used for modpath delays and * they are required to be non-negative. */ -vvp_time64_t vpip_scaled_real_to_time64(double val, __vpiScope*scope) +vvp_time64_t vpip_scaled_real_to_time64(double val, const __vpiScope*scope) { int shift = 0; if (scope) shift = scope->time_units - scope->time_precision; @@ -107,7 +107,7 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp, bool is_int_func, int units = rfp->scope? rfp->scope->time_units : vpi_time_precision; static const size_t RBUF_USE_SIZE = 128; - char*rbuf = (char *) need_result_buf(RBUF_USE_SIZE, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(RBUF_USE_SIZE, RBUF_VAL)); /* Calculate the divisor needed to scale the simulation time (in time_precision units) to time units of the scope. */ diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index 7a3d0bd38..503eff6a3 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -70,7 +70,7 @@ class __vpiVThrWord : public __vpiHandle { static int vthr_word_get(int code, vpiHandle ref) { - __vpiVThrWord*rfp = dynamic_cast<__vpiVThrWord*>(ref); + const __vpiVThrWord*rfp = dynamic_cast<__vpiVThrWord*>(ref); switch (code) { @@ -98,9 +98,9 @@ static double vlg_round(double rval) static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp) { - __vpiVThrWord*obj = dynamic_cast<__vpiVThrWord*>(ref); + const __vpiVThrWord*obj = dynamic_cast<__vpiVThrWord*>(ref); static const size_t RBUF_USE_SIZE = 66; - char *rbuf = (char *) need_result_buf(RBUF_USE_SIZE, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(RBUF_USE_SIZE, RBUF_VAL)); double val = 0.0; @@ -271,7 +271,7 @@ void __vpiVThrStrStack::vpi_get_value(p_vpi_value vp) vp->format = vpiStringVal; // fallthrough case vpiStringVal: - rbuf = (char *) need_result_buf(val.size()+1, RBUF_VAL); + rbuf = static_cast(need_result_buf(val.size()+1, RBUF_VAL)); strcpy(rbuf, val.c_str()); vp->value.str = rbuf; break; @@ -404,7 +404,7 @@ void __vpiVThrVec4Stack::vpi_get_value(p_vpi_value vp) void __vpiVThrVec4Stack::vpi_get_value_binstr_(p_vpi_value vp, const vvp_vector4_t&val) { unsigned wid = val.size(); - char*rbuf = (char*) need_result_buf(wid+1, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(wid+1, RBUF_VAL)); for (unsigned idx = 0 ; idx < wid ; idx += 1) { rbuf[wid-idx-1] = vvp_bit4_to_ascii(val.value(idx)); } @@ -416,7 +416,7 @@ void __vpiVThrVec4Stack::vpi_get_value_decstr_(p_vpi_value vp, const vvp_vector4 { unsigned wid = val.size(); int nbuf = (wid+2)/3 + 1; - char *rbuf = (char*) need_result_buf(nbuf, RBUF_VAL); + char *rbuf = static_cast(need_result_buf(nbuf, RBUF_VAL)); vpip_vec4_to_dec_str(val, rbuf, nbuf, signed_flag_); vp->value.str = rbuf; @@ -426,7 +426,7 @@ void __vpiVThrVec4Stack::vpi_get_value_octstr_(p_vpi_value vp, const vvp_vector4 { unsigned wid = val.size(); unsigned owid = (wid + 2) / 3; - char*rbuf = (char*) need_result_buf(owid+1, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(owid+1, RBUF_VAL)); rbuf[owid] = 0; unsigned oval = 0; @@ -467,7 +467,7 @@ void __vpiVThrVec4Stack::vpi_get_value_hexstr_(p_vpi_value vp, const vvp_vector4 { unsigned wid = val.size(); unsigned hwid = (wid + 3) /4; - char*rbuf = (char*) need_result_buf(hwid+1, RBUF_VAL); + char*rbuf = static_cast(need_result_buf(hwid+1, RBUF_VAL)); rbuf[hwid] = 0; unsigned hval = 0; @@ -524,7 +524,7 @@ void __vpiVThrVec4Stack::vpi_get_value_real_(p_vpi_value vp, const vvp_vector4_t void __vpiVThrVec4Stack::vpi_get_value_string_(p_vpi_value vp, const vvp_vector4_t&val) { - char*rbuf = (char*) need_result_buf((val.size() / 8) + 1, RBUF_VAL); + char*rbuf = static_cast(need_result_buf((val.size() / 8) + 1, RBUF_VAL)); char*cp = rbuf; char tmp = 0; @@ -557,8 +557,8 @@ void __vpiVThrVec4Stack::vpi_get_value_vector_(p_vpi_value vp, const vvp_vector4 { unsigned wid = val.size(); - vp->value.vector = (s_vpi_vecval*) - need_result_buf((wid+31)/32*sizeof(s_vpi_vecval), RBUF_VAL); + vp->value.vector = static_cast + (need_result_buf((wid+31)/32*sizeof(s_vpi_vecval), RBUF_VAL)); assert(vp->value.vector); for (unsigned idx = 0 ; idx < wid ; idx += 1) { @@ -588,8 +588,9 @@ void __vpiVThrVec4Stack::vpi_get_value_vector_(p_vpi_value vp, const vvp_vector4 void __vpiVThrVec4Stack::vpi_get_value_strength_(p_vpi_value vp, const vvp_vector4_t&val) { - s_vpi_strengthval*op = (s_vpi_strengthval*) - need_result_buf(val.size() * sizeof(s_vpi_strengthval), RBUF_VAL); + s_vpi_strengthval*op = static_cast + (need_result_buf(val.size() * sizeof(s_vpi_strengthval), + RBUF_VAL)); for (unsigned idx = 0 ; idx < val.size() ; idx += 1) { switch (val.value(idx)) { diff --git a/vvp/vpip_to_dec.cc b/vvp/vpip_to_dec.cc index ce11e5153..5bb686d62 100644 --- a/vvp/vpip_to_dec.cc +++ b/vvp/vpip_to_dec.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2011 Stephen Williams + * Copyright (c) 2008-2025 Stephen Williams * Copyright (c) 2002 Larry Doolittle (larry@doolittle.boa.org) * * This source code is free software; you can redistribute it @@ -150,7 +150,8 @@ unsigned vpip_vec4_to_dec_str(const vvp_vector4_t&vec4, #define ALLOC_MARGIN 4 if (!valv || vlen > vlen_alloc) { if (valv) free(valv); - valv = (unsigned long*) calloc(vlen+ALLOC_MARGIN, sizeof (*valv)); + valv = static_cast + (calloc(vlen+ALLOC_MARGIN, sizeof (*valv))); vlen_alloc=vlen+ALLOC_MARGIN; } else { memset(valv,0,vlen*sizeof(valv[0])); diff --git a/vvp/vvp_darray.h b/vvp/vvp_darray.h index 158d7843f..7d6cabebf 100644 --- a/vvp/vvp_darray.h +++ b/vvp/vvp_darray.h @@ -29,7 +29,7 @@ class vvp_darray : public vvp_object { public: inline vvp_darray() { } - virtual ~vvp_darray(); + virtual ~vvp_darray() override; virtual size_t get_size(void) const =0; @@ -52,7 +52,7 @@ template class vvp_darray_atom : public vvp_darray { public: explicit inline vvp_darray_atom(size_t siz) : array_(siz) { } - ~vvp_darray_atom(); + ~vvp_darray_atom() override; size_t get_size(void) const override; void set_word(unsigned adr, const vvp_vector4_t&value) override; @@ -184,7 +184,7 @@ class vvp_queue : public vvp_darray { class vvp_queue_real : public vvp_queue { public: - ~vvp_queue_real(); + ~vvp_queue_real() override; size_t get_size(void) const override { return queue.size(); }; void copy_elems(vvp_object_t src, unsigned max_size) override; @@ -206,7 +206,7 @@ class vvp_queue_real : public vvp_queue { class vvp_queue_string : public vvp_queue { public: - ~vvp_queue_string(); + ~vvp_queue_string() override; size_t get_size(void) const override { return queue.size(); }; void copy_elems(vvp_object_t src, unsigned max_size) override; @@ -228,7 +228,7 @@ class vvp_queue_string : public vvp_queue { class vvp_queue_vec4 : public vvp_queue { public: - ~vvp_queue_vec4(); + ~vvp_queue_vec4() override; size_t get_size(void) const override { return queue.size(); }; void copy_elems(vvp_object_t src, unsigned max_size) override; diff --git a/vvp/vvp_net_sig.cc b/vvp/vvp_net_sig.cc index cb8b29b35..fea30ce60 100644 --- a/vvp/vvp_net_sig.cc +++ b/vvp/vvp_net_sig.cc @@ -409,7 +409,7 @@ unsigned vvp_fun_signal4_aa::value_size() const vvp_bit4_t vvp_fun_signal4_aa::value(unsigned idx) const { - vvp_vector4_t*bits4 = static_cast + const vvp_vector4_t*bits4 = static_cast (vthread_get_rd_context_item(context_idx_)); return bits4->value(idx); @@ -417,7 +417,7 @@ vvp_bit4_t vvp_fun_signal4_aa::value(unsigned idx) const vvp_scalar_t vvp_fun_signal4_aa::scalar_value(unsigned idx) const { - vvp_vector4_t*bits4 = static_cast + const vvp_vector4_t*bits4 = static_cast (vthread_get_rd_context_item(context_idx_)); return vvp_scalar_t(bits4->value(idx), 6, 6); @@ -425,7 +425,7 @@ vvp_scalar_t vvp_fun_signal4_aa::scalar_value(unsigned idx) const void vvp_fun_signal4_aa::vec4_value(vvp_vector4_t&val) const { - vvp_vector4_t*bits4 = static_cast + const vvp_vector4_t*bits4 = static_cast (vthread_get_rd_context_item(context_idx_)); val = *bits4; @@ -433,7 +433,7 @@ void vvp_fun_signal4_aa::vec4_value(vvp_vector4_t&val) const const vvp_vector4_t&vvp_fun_signal4_aa::vec4_unfiltered_value() const { - vvp_vector4_t*bits4 = static_cast + const vvp_vector4_t*bits4 = static_cast (vthread_get_rd_context_item(context_idx_)); return *bits4; @@ -528,7 +528,7 @@ void vvp_fun_signal_real_aa::free_instance(vvp_context_t context) double vvp_fun_signal_real_aa::real_unfiltered_value() const { - double*bits = static_cast + const double*bits = static_cast (vthread_get_rd_context_item(context_idx_)); return *bits; @@ -688,7 +688,7 @@ double vvp_fun_signal_string_aa::real_value() const const std::string& vvp_fun_signal_string_aa::get_string() const { - string*bits = static_cast + const string*bits = static_cast (vthread_get_rd_context_item(context_idx_)); return *bits; @@ -765,7 +765,7 @@ void vvp_fun_signal_object_aa::reset_instance(vvp_context_t context) vvp_object_t vvp_fun_signal_object_aa::get_object() const { - vvp_object_t*bits = static_cast + const vvp_object_t*bits = static_cast (vthread_get_rd_context_item(context_idx_)); return *bits; } diff --git a/vvp/words.cc b/vvp/words.cc index 672c8faf4..630c430b0 100644 --- a/vvp/words.cc +++ b/vvp/words.cc @@ -190,7 +190,7 @@ void compile_variable(char*label, char*name, net->fil = new vvp_wire_vec4(wid, init); net->fun = new vvp_fun_signal4_sa(wid); } - vvp_signal_value*vfil = dynamic_cast(net->fil); + const vvp_signal_value*vfil = dynamic_cast(net->fil); define_functor_symbol(label, net); @@ -295,7 +295,7 @@ class __compile_net_resolv : public base_net_resolv { signed_flag_ = signed_flag; } - ~__compile_net_resolv() { } + ~__compile_net_resolv() override { } bool resolve(bool message_flag) override; @@ -457,7 +457,7 @@ class __compile_real_net_resolv : public base_net_resolv { { } - ~__compile_real_net_resolv() { } + ~__compile_real_net_resolv() override { } bool resolve(bool message_flag) override;