From 95ffc97f5f1242dc55c50df3e841c3289f6f3dca Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 8 Dec 2025 20:39:47 -0800 Subject: [PATCH] Some cppcheck cleanup for vhdlpp --- cppcheck-global.sup | 2 + vhdlpp/Makefile.in | 1 + vhdlpp/architec.cc | 8 +- vhdlpp/architec.h | 68 +++--- vhdlpp/architec_elaborate.cc | 4 +- vhdlpp/cppcheck.sup | 9 + vhdlpp/entity.h | 6 +- vhdlpp/expression.h | 428 +++++++++++++++++------------------ vhdlpp/package.cc | 8 +- vhdlpp/package.h | 4 +- vhdlpp/scope.h | 6 +- vhdlpp/sequential.h | 136 +++++------ vhdlpp/std_funcs.cc | 10 +- vhdlpp/subprogram.cc | 4 +- vhdlpp/subprogram.h | 20 +- vhdlpp/vsignal.h | 4 +- vhdlpp/vtype.h | 118 +++++----- 17 files changed, 424 insertions(+), 412 deletions(-) create mode 100644 vhdlpp/cppcheck.sup diff --git a/cppcheck-global.sup b/cppcheck-global.sup index f14df5655..c836f6bff 100644 --- a/cppcheck-global.sup +++ b/cppcheck-global.sup @@ -1,3 +1,5 @@ +// For now skip using STL algorithms +useStlAlgorithm // Skip all messages about missing system include files missingIncludeSystem // Skip the active checker report message diff --git a/vhdlpp/Makefile.in b/vhdlpp/Makefile.in index 2fdaf18c8..b6c17587e 100644 --- a/vhdlpp/Makefile.in +++ b/vhdlpp/Makefile.in @@ -88,6 +88,7 @@ cppcheck: $(O:.o=.cc) cppcheck --enable=all --std=c99 --std=c++11 -f \ --check-level=exhaustive \ --suppressions-list=$(srcdir)/../cppcheck-global.sup \ + --suppressions-list=$(srcdir)/cppcheck.sup \ -UYY_USER_INIT \ -UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \ -UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \ diff --git a/vhdlpp/architec.cc b/vhdlpp/architec.cc index 488ee9cd5..1b1764dfa 100644 --- a/vhdlpp/architec.cc +++ b/vhdlpp/architec.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-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 @@ -52,7 +52,7 @@ bool Architecture::find_constant(perm_string by_name, const VType*&typ, Expressi c = old_components_.find(cur_component_->component_name()); assert(c != old_components_.end()); - ComponentBase*base = c->second; + const ComponentBase*base = c->second; const InterfacePort*generic = base->find_generic(by_name); if(!generic) @@ -209,7 +209,7 @@ ComponentInstantiation::ComponentInstantiation(perm_string i, perm_string c, typedef pair::iterator,bool> insert_rc; while (parms && ! parms->empty()) { - named_expr_t*cur = parms->front(); + const named_expr_t*cur = parms->front(); parms->pop_front(); insert_rc rc = generic_map_.insert(make_pair(cur->name(), cur->expr())); if (! rc.second) { @@ -220,7 +220,7 @@ ComponentInstantiation::ComponentInstantiation(perm_string i, perm_string c, } while (ports && ! ports->empty()) { - named_expr_t*cur = ports->front(); + const named_expr_t*cur = ports->front(); ports->pop_front(); insert_rc rc = port_map_.insert(make_pair(cur->name(), cur->expr())); if (! rc.second) { diff --git a/vhdlpp/architec.h b/vhdlpp/architec.h index 6602ad5e1..6dabcc2eb 100644 --- a/vhdlpp/architec.h +++ b/vhdlpp/architec.h @@ -1,7 +1,7 @@ #ifndef IVL_architec_H #define IVL_architec_H /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-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 @@ -50,7 +50,7 @@ class Architecture : public Scope, public LineInfo { public: Statement(); - virtual ~Statement() =0; + virtual ~Statement() override =0; virtual int elaborate(Entity*ent, Architecture*arc); virtual int emit(std::ostream&out, Entity*ent, Architecture*arc); @@ -62,12 +62,12 @@ class Architecture : public Scope, public LineInfo { // NOTE: The statement list passed in is emptied. Architecture(perm_string name, const ActiveScope&ref, std::list&s); - ~Architecture(); + ~Architecture() override; perm_string get_name() const { return name_; } - bool find_constant(perm_string by_name, const VType*&typ, Expression*&exp) const; - Variable* find_variable(perm_string by_name) const; + bool find_constant(perm_string by_name, const VType*&typ, Expression*&exp) const override; + Variable* find_variable(perm_string by_name) const override; // Sets the currently processed component (to be able to reach its parameters). void set_cur_component(ComponentInstantiation*component) { @@ -137,7 +137,7 @@ class GenerateStatement : public Architecture::Statement { public: GenerateStatement(perm_string gname, std::list&s); - ~GenerateStatement(); + ~GenerateStatement() override; inline perm_string get_name() const { return name_; } @@ -156,10 +156,10 @@ class ForGenerate : public GenerateStatement { public: ForGenerate(perm_string gname, perm_string genvar, ExpRange*rang, std::list&s); - ~ForGenerate(); + ~ForGenerate() override; - int elaborate(Entity*ent, Architecture*arc); - int emit(std::ostream&out, Entity*entity, Architecture*arc); + int elaborate(Entity*ent, Architecture*arc) override; + int emit(std::ostream&out, Entity*entity, Architecture*arc) override; void dump(std::ostream&out, int ident =0) const; private: @@ -173,10 +173,10 @@ class IfGenerate : public GenerateStatement { public: IfGenerate(perm_string gname, Expression*cond, std::list&s); - ~IfGenerate(); + ~IfGenerate() override; - int elaborate(Entity*ent, Architecture*arc); - int emit(std::ostream&out, Entity*entity, Architecture*arc); + int elaborate(Entity*ent, Architecture*arc) override; + int emit(std::ostream&out, Entity*entity, Architecture*arc) override; private: Expression*cond_; @@ -191,10 +191,10 @@ class SignalAssignment : public Architecture::Statement { public: SignalAssignment(ExpName*target, std::list&rval); SignalAssignment(ExpName*target, Expression*rval); - ~SignalAssignment(); + ~SignalAssignment() override; - virtual int elaborate(Entity*ent, Architecture*arc); - virtual int emit(std::ostream&out, Entity*entity, Architecture*arc); + virtual int elaborate(Entity*ent, Architecture*arc) override; + virtual int emit(std::ostream&out, Entity*entity, Architecture*arc) override; virtual void dump(std::ostream&out, int ident =0) const; private: @@ -206,10 +206,10 @@ class CondSignalAssignment : public Architecture::Statement { public: CondSignalAssignment(ExpName*target, std::list&options); - ~CondSignalAssignment(); + ~CondSignalAssignment() override; - int elaborate(Entity*ent, Architecture*arc); - int emit(std::ostream&out, Entity*entity, Architecture*arc); + int elaborate(Entity*ent, Architecture*arc) override; + int emit(std::ostream&out, Entity*entity, Architecture*arc) override; void dump(std::ostream&out, int ident =0) const; private: @@ -227,11 +227,11 @@ class ComponentInstantiation : public Architecture::Statement { ComponentInstantiation(perm_string iname, perm_string cname, std::list*parms, std::list*ports); - ~ComponentInstantiation(); + ~ComponentInstantiation() override; - virtual int elaborate(Entity*ent, Architecture*arc); - virtual int emit(std::ostream&out, Entity*entity, Architecture*arc); - virtual void dump(std::ostream&out, int indent =0) const; + virtual int elaborate(Entity*ent, Architecture*arc) override; + virtual int emit(std::ostream&out, Entity*entity, Architecture*arc) override; + virtual void dump(std::ostream&out, int indent =0) const override; // Returns the expression that initializes a generic (or NULL if not found). Expression*find_generic_map(perm_string by_name) const; @@ -250,19 +250,19 @@ class ComponentInstantiation : public Architecture::Statement { class StatementList : public Architecture::Statement { public: explicit StatementList(std::list*statement_list); - virtual ~StatementList(); + virtual ~StatementList() override; - int elaborate(Entity*ent, Architecture*arc) { + int elaborate(Entity*ent, Architecture*arc) override { return elaborate(ent, static_cast(arc)); } - int emit(std::ostream&out, Entity*ent, Architecture*arc) { + int emit(std::ostream&out, Entity*ent, Architecture*arc) override { return emit(out, ent, static_cast(arc)); } virtual int elaborate(Entity*ent, ScopeBase*scope); virtual int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - virtual void dump(std::ostream&out, int indent =0) const; + virtual void dump(std::ostream&out, int indent =0) const override; std::list& stmt_list() { return statements_; } @@ -277,8 +277,8 @@ class InitialStatement : public StatementList { explicit InitialStatement(std::list*statement_list) : StatementList(statement_list) {} - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void dump(std::ostream&out, int indent =0) const; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void dump(std::ostream&out, int indent =0) const override; }; // There is no direct VHDL counterpart to SV 'final' statement, @@ -288,8 +288,8 @@ class FinalStatement : public StatementList { explicit FinalStatement(std::list*statement_list) : StatementList(statement_list) {} - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void dump(std::ostream&out, int indent =0) const; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void dump(std::ostream&out, int indent =0) const override; }; class ProcessStatement : public StatementList, public Scope { @@ -299,11 +299,11 @@ class ProcessStatement : public StatementList, public Scope { const ActiveScope&ref, std::list*sensitivity_list, std::list*statement_list); - ~ProcessStatement(); + ~ProcessStatement() override; - int elaborate(Entity*ent, Architecture*arc); - int emit(std::ostream&out, Entity*entity, Architecture*arc); - void dump(std::ostream&out, int indent =0) const; + int elaborate(Entity*ent, Architecture*arc) override; + int emit(std::ostream&out, Entity*entity, Architecture*arc) override; + void dump(std::ostream&out, int indent =0) const override; private: perm_string iname_; diff --git a/vhdlpp/architec_elaborate.cc b/vhdlpp/architec_elaborate.cc index fc742213e..4ec913e29 100644 --- a/vhdlpp/architec_elaborate.cc +++ b/vhdlpp/architec_elaborate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-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 @@ -105,7 +105,7 @@ int ComponentInstantiation::elaborate(Entity*ent, Architecture*arc) { int errors = 0; - ComponentBase*base = arc->find_component(cname_); + const ComponentBase*base = arc->find_component(cname_); if (base == 0) { cerr << get_fileline() << ": error: No component declaration" << " for instance " << iname_ diff --git a/vhdlpp/cppcheck.sup b/vhdlpp/cppcheck.sup new file mode 100644 index 000000000..bfae2213f --- /dev/null +++ b/vhdlpp/cppcheck.sup @@ -0,0 +1,9 @@ + +// Errors/limitations in the generated yacc and lex files +cstyleCast:lexor.cc +constVariablePointer:lexor.cc +duplicateBreak:lexor.lex +unusedFunction:lexor.cc +unusedStructMember:lexor.cc +constParameterPointer:parse.cc +syntaxError:parse.cc diff --git a/vhdlpp/entity.h b/vhdlpp/entity.h index eced5eab8..14ade86fc 100644 --- a/vhdlpp/entity.h +++ b/vhdlpp/entity.h @@ -1,7 +1,7 @@ #ifndef IVL_entity_H #define IVL_entity_H /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-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 @@ class ComponentBase : public LineInfo { public: explicit ComponentBase(perm_string name); - ~ComponentBase(); + ~ComponentBase() override; // Entities have names. perm_string get_name() const { return name_; } @@ -106,7 +106,7 @@ class Entity : public ComponentBase { public: explicit Entity(perm_string name); - ~Entity(); + ~Entity() override; // bind an architecture to the entity, and return the // Architecture that was bound. If there was a previous diff --git a/vhdlpp/expression.h b/vhdlpp/expression.h index 8c0a7e531..ad69cd2da 100644 --- a/vhdlpp/expression.h +++ b/vhdlpp/expression.h @@ -73,7 +73,7 @@ class Expression : public LineInfo { public: Expression(); - virtual ~Expression() =0; + virtual ~Expression() override =0; // Returns a deep copy of the expression. virtual Expression*clone() const =0; @@ -184,14 +184,14 @@ class ExpUnary : public Expression { public: explicit ExpUnary(Expression*op1); - virtual ~ExpUnary() =0; + virtual ~ExpUnary() override =0; inline const Expression*peek_operand() const { return operand1_; } - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void visit(ExprVisitor& func); + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void visit(ExprVisitor& func) override; protected: inline void write_to_stream_operand1(std::ostream&fd) const @@ -212,13 +212,13 @@ class ExpBinary : public Expression { public: ExpBinary(Expression*op1, Expression*op2); - virtual ~ExpBinary() =0; + virtual ~ExpBinary() override =0; inline const Expression* peek_operand1(void) const { return operand1_; } inline const Expression* peek_operand2(void) const { return operand2_; } - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - void visit(ExprVisitor& func); + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + void visit(ExprVisitor& func) override; protected: @@ -326,16 +326,16 @@ class ExpAggregate : public Expression { public: explicit ExpAggregate(std::list*el); - ~ExpAggregate(); + ~ExpAggregate() override; - Expression*clone() const; + Expression*clone() const override; - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; private: int elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype); @@ -359,20 +359,20 @@ class ExpArithmetic : public ExpBinary { public: ExpArithmetic(ExpArithmetic::fun_t op, Expression*op1, Expression*op2); - ~ExpArithmetic(); + ~ExpArithmetic() override; - Expression*clone() const { + Expression*clone() const override { return new ExpArithmetic(fun_, peek_operand1()->clone(), peek_operand2()->clone()); } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - virtual bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - void dump(std::ostream&out, int indent = 0) const; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + virtual bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override; + void dump(std::ostream&out, int indent = 0) const override; private: - const VType* resolve_operand_types_(const VType*t1, const VType*t2) const; + const VType* resolve_operand_types_(const VType*t1, const VType*t2) const override; private: fun_t fun_; @@ -382,7 +382,7 @@ class ExpAttribute : public Expression { public: ExpAttribute(perm_string name,std::list*args); - virtual ~ExpAttribute(); + virtual ~ExpAttribute() override; inline perm_string peek_attribute() const { return name_; } @@ -405,20 +405,20 @@ class ExpAttribute : public Expression { class ExpObjAttribute : public ExpAttribute { public: ExpObjAttribute(ExpName*base, perm_string name, std::list*args); - ~ExpObjAttribute(); + ~ExpObjAttribute() override; - Expression*clone() const; + Expression*clone() const override; inline const ExpName* peek_base() const { return base_; } - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; // Some attributes can be evaluated at compile time - bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; private: ExpName*base_; @@ -429,19 +429,19 @@ class ExpTypeAttribute : public ExpAttribute { ExpTypeAttribute(const VType*base, perm_string name, std::list*args); // no destructor - VType objects (base_) are shared between many expressions - Expression*clone() const; + Expression*clone() const override; inline const VType* peek_base() const { return base_; } - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; // Some attributes can be evaluated at compile time bool evaluate(ScopeBase*scope, int64_t&val) const; - bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; private: const VType*base_; @@ -452,15 +452,15 @@ class ExpBitstring : public Expression { public: explicit ExpBitstring(const char*); ExpBitstring(const ExpBitstring&other) : Expression() { value_ = other.value_; } - ~ExpBitstring(); + ~ExpBitstring() override; - Expression*clone() const { return new ExpBitstring(*this); } + Expression*clone() const override { return new ExpBitstring(*this); } - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; private: std::vectorvalue_; @@ -472,16 +472,16 @@ class ExpCharacter : public Expression { public: explicit ExpCharacter(char val); ExpCharacter(const ExpCharacter&other) : Expression() { value_ = other.value_; } - ~ExpCharacter(); + ~ExpCharacter() override; - Expression*clone() const { return new ExpCharacter(*this); } + Expression*clone() const override { return new ExpCharacter(*this); } - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - bool is_primary(void) const; - void dump(std::ostream&out, int indent = 0) const; + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + bool is_primary(void) const override; + void dump(std::ostream&out, int indent = 0) const override; char value() const { return value_; } @@ -497,20 +497,20 @@ class ExpConcat : public Expression { public: ExpConcat(Expression*op1, Expression*op2); - ~ExpConcat(); + ~ExpConcat() override; - Expression*clone() const { + Expression*clone() const override { return new ExpConcat(operand1_->clone(), operand2_->clone()); } - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - bool is_primary(void) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + bool is_primary(void) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; private: int elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype); @@ -553,16 +553,16 @@ class ExpConditional : public Expression { public: ExpConditional(Expression*cond, std::list*tru, std::list*options); - virtual ~ExpConditional(); + virtual ~ExpConditional() override; - virtual Expression*clone() const; + virtual Expression*clone() const override; - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; protected: std::list options_; @@ -574,9 +574,9 @@ class ExpConditional : public Expression { class ExpSelected : public ExpConditional { public: ExpSelected(Expression*selector, std::list*options); - ~ExpSelected(); + ~ExpSelected() override; - Expression*clone() const; + Expression*clone() const override; private: Expression*selector_; @@ -593,15 +593,15 @@ class ExpEdge : public ExpUnary { public: explicit ExpEdge(ExpEdge::fun_t ty, Expression*op); - ~ExpEdge(); + ~ExpEdge() override; - Expression*clone() const { return new ExpEdge(fun_, peek_operand()->clone()); } + Expression*clone() const override { return new ExpEdge(fun_, peek_operand()->clone()); } inline fun_t edge_fun() const { return fun_; } - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; private: fun_t fun_; @@ -612,23 +612,23 @@ class ExpFunc : public Expression { public: explicit ExpFunc(perm_string nn); ExpFunc(perm_string nn, std::list*args); - ~ExpFunc(); + ~ExpFunc() override; - Expression*clone() const; + Expression*clone() const override; - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; inline perm_string func_name() const { return name_; } inline size_t func_args() const { return argv_.size(); } inline const Expression*func_arg(size_t idx) const { return argv_[idx]; } const VType*func_ret_type() const; public: // Base methods - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); // NOTE: does not handle expressions in subprogram body + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; // NOTE: does not handle expressions in subprogram body // Returns a subprogram header that matches the function call SubprogramHeader*match_signature(Entity*ent, ScopeBase*scope) const; @@ -644,19 +644,19 @@ class ExpInteger : public Expression { public: explicit ExpInteger(int64_t val); ExpInteger(const ExpInteger&other) : Expression(), value_(other.value_) {} - ~ExpInteger(); + ~ExpInteger() override; - Expression*clone() const { return new ExpInteger(*this); } + Expression*clone() const override { return new ExpInteger(*this); } - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - int emit_package(std::ostream&out) const; - bool is_primary(void) const { return true; } - bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - void dump(std::ostream&out, int indent = 0) const; - virtual std::ostream& dump_inline(std::ostream&out) const; + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + int emit_package(std::ostream&out) const override; + bool is_primary(void) const override { return true; } + bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override; + void dump(std::ostream&out, int indent = 0) const override; + virtual std::ostream& dump_inline(std::ostream&out) const override; private: int64_t value_; @@ -667,18 +667,18 @@ class ExpReal : public Expression { public: explicit ExpReal(double val); ExpReal(const ExpReal&other) : Expression(), value_(other.value_) {} - ~ExpReal(); + ~ExpReal() override; - Expression*clone() const { return new ExpReal(*this); } + Expression*clone() const override { return new ExpReal(*this); } - const VType*probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - int emit_package(std::ostream&out) const; - bool is_primary(void) const; - void dump(std::ostream&out, int indent = 0) const; - virtual std::ostream& dump_inline(std::ostream&out) const; + const VType*probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + int emit_package(std::ostream&out) const override; + bool is_primary(void) const override; + void dump(std::ostream&out, int indent = 0) const override; + virtual std::ostream& dump_inline(std::ostream&out) const override; private: double value_; @@ -691,18 +691,18 @@ class ExpLogical : public ExpBinary { public: ExpLogical(ExpLogical::fun_t ty, Expression*op1, Expression*op2); - ~ExpLogical(); + ~ExpLogical() override; - Expression*clone() const { + Expression*clone() const override { return new ExpLogical(fun_, peek_operand1()->clone(), peek_operand2()->clone()); } inline fun_t logic_fun() const { return fun_; } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; private: fun_t fun_; @@ -719,26 +719,26 @@ class ExpName : public Expression { explicit ExpName(perm_string nn); ExpName(perm_string nn, std::list*indices); ExpName(ExpName*prefix, perm_string nn, std::list*indices = NULL); - virtual ~ExpName(); + virtual ~ExpName() override; public: // Base methods - Expression*clone() const; - int elaborate_lval(Entity*ent, ScopeBase*scope, bool); + Expression*clone() const override; + int elaborate_lval(Entity*ent, ScopeBase*scope, bool) override; int elaborate_rval(const Entity*ent, const ScopeBase*scope, const InterfacePort*); - const VType* probe_type(Entity*ent, ScopeBase*scope) const; - const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; + const VType* probe_type(Entity*ent, ScopeBase*scope) const override; + const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; int emit_indices(std::ostream&out, Entity*ent, ScopeBase*scope) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - bool is_primary(void) const; - bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - bool symbolic_compare(const Expression*that) const; - void dump(std::ostream&out, int indent = 0) const; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + bool is_primary(void) const override; + bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override; + bool symbolic_compare(const Expression*that) const override; + void dump(std::ostream&out, int indent = 0) const override; inline const char* name() const { return name_; } inline const perm_string& peek_name() const { return name_; } void add_index(std::list*idx); - void visit(ExprVisitor& func); + void visit(ExprVisitor& func) override; private: class index_t { @@ -797,8 +797,8 @@ class ExpNameALL : public ExpName { ExpNameALL() : ExpName(empty_perm_string) { } public: - const VType* probe_type(Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent =0) const; + const VType* probe_type(Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent =0) const override; }; class ExpRelation : public ExpBinary { @@ -810,17 +810,17 @@ class ExpRelation : public ExpBinary { public: ExpRelation(ExpRelation::fun_t ty, Expression*op1, Expression*op2); - ~ExpRelation(); + ~ExpRelation() override; - Expression*clone() const { + Expression*clone() const override { return new ExpRelation(fun_, peek_operand1()->clone(), peek_operand2()->clone()); } - const VType* probe_type(Entity*ent, ScopeBase*scope) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + const VType* probe_type(Entity*ent, ScopeBase*scope) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; private: fun_t fun_; @@ -833,46 +833,46 @@ class ExpRelation : public ExpBinary { class ExpScopedName : public Expression { public: ExpScopedName(perm_string scope, ExpName*exp); - ~ExpScopedName(); + ~ExpScopedName() override; - Expression*clone() const + Expression*clone() const override { return new ExpScopedName(scope_name_, static_cast(name_->clone())); } - int elaborate_lval(Entity*ent, ScopeBase*scope, bool is_sequ) + int elaborate_lval(Entity*ent, ScopeBase*scope, bool is_sequ) override { return name_->elaborate_lval(ent, get_scope(scope), is_sequ); } int elaborate_rval(const Entity*ent, const ScopeBase*scope, const InterfacePort*lval) { return name_->elaborate_rval(ent, get_scope(scope), lval); } - const VType* probe_type(Entity*ent, ScopeBase*scope) const + const VType* probe_type(Entity*ent, ScopeBase*scope) const override { return name_->probe_type(ent, get_scope(scope)); } - const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const + const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const override { return name_->fit_type(ent, get_scope(scope), host); } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override { return name_->elaborate_expr(ent, get_scope(scope), ltype); } - void write_to_stream(std::ostream&fd) const + void write_to_stream(std::ostream&fd) const override { name_->write_to_stream(fd); } - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const { + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override { out << scope_name_ << "."; return name_->emit(out, ent, scope); } - bool is_primary(void) const + bool is_primary(void) const override { return name_->is_primary(); } - bool evaluate(Entity*ent, ScopeBase*, int64_t&val) const + bool evaluate(Entity*ent, ScopeBase*, int64_t&val) const override { return name_->evaluate(ent, scope_, val); } - bool symbolic_compare(const Expression*that) const + bool symbolic_compare(const Expression*that) const override { return name_->symbolic_compare(that); } - void dump(std::ostream&out, int indent = 0) const; + void dump(std::ostream&out, int indent = 0) const override; - void visit(ExprVisitor&func); + void visit(ExprVisitor&func) override; private: // Functions that resolve the origin scope for the name expression @@ -891,15 +891,15 @@ class ExpShift : public ExpBinary { public: ExpShift(ExpShift::shift_t op, Expression*op1, Expression*op2); - Expression*clone() const { + Expression*clone() const override { return new ExpShift(shift_, peek_operand1()->clone(), peek_operand2()->clone()); } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - void dump(std::ostream&out, int indent = 0) const; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override; + void dump(std::ostream&out, int indent = 0) const override; private: shift_t shift_; @@ -910,16 +910,16 @@ class ExpString : public Expression { public: explicit ExpString(const char*); ExpString(const ExpString&other) : Expression(), value_(other.value_) {} - ~ExpString(); + ~ExpString() override; - Expression*clone() const { return new ExpString(*this); } + Expression*clone() const override { return new ExpString(*this); } - const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - bool is_primary(void) const; - void dump(std::ostream&out, int indent = 0) const; + const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const override; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + bool is_primary(void) const override; + void dump(std::ostream&out, int indent = 0) const override; const std::string& get_value() const { return value_; } // Converts quotation marks (") to its escaped @@ -937,39 +937,39 @@ class ExpUAbs : public ExpUnary { public: explicit ExpUAbs(Expression*op1); - ~ExpUAbs(); + ~ExpUAbs() override; - Expression*clone() const { return new ExpUAbs(peek_operand()->clone()); } + Expression*clone() const override { return new ExpUAbs(peek_operand()->clone()); } - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; }; class ExpUNot : public ExpUnary { public: explicit ExpUNot(Expression*op1); - ~ExpUNot(); + ~ExpUNot() override; - Expression*clone() const { return new ExpUNot(peek_operand()->clone()); } + Expression*clone() const override { return new ExpUNot(peek_operand()->clone()); } - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; }; class ExpUMinus : public ExpUnary { public: explicit ExpUMinus(Expression*op1); - ~ExpUMinus(); + ~ExpUMinus() override; - Expression*clone() const { return new ExpUMinus(peek_operand()->clone()); } + Expression*clone() const override { return new ExpUMinus(peek_operand()->clone()); } - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; }; /* @@ -979,17 +979,17 @@ class ExpCast : public Expression { public: ExpCast(Expression*base, const VType*type); - ~ExpCast(); + ~ExpCast() override; - Expression*clone() const { return new ExpCast(base_->clone(), type_->clone()); } + Expression*clone() const override { return new ExpCast(base_->clone(), type_->clone()); } - inline int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*) { + inline int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*) override { return base_->elaborate_expr(ent, scope, type_); } - void write_to_stream(std::ostream&fd) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + void write_to_stream(std::ostream&fd) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; private: Expression*base_; @@ -1004,15 +1004,15 @@ class ExpNew : public Expression { public: explicit ExpNew(Expression*size); - ~ExpNew(); + ~ExpNew() override; - Expression*clone() const { return new ExpNew(size_->clone()); } + Expression*clone() const override { return new ExpNew(size_->clone()); } // There is no 'new' in VHDL - do not emit anything - void write_to_stream(std::ostream&) const {}; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + void write_to_stream(std::ostream&) const override {}; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; private: Expression*size_; @@ -1024,13 +1024,13 @@ class ExpTime : public Expression { ExpTime(uint64_t amount, timeunit_t unit); - Expression*clone() const { return new ExpTime(amount_, unit_); } + Expression*clone() const override { return new ExpTime(amount_, unit_); } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; //bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; - void dump(std::ostream&out, int indent = 0) const; + void dump(std::ostream&out, int indent = 0) const override; private: // Returns the time value expressed in femtoseconds @@ -1047,9 +1047,9 @@ class ExpRange : public Expression { ExpRange(Expression*left_idx, Expression*right_idx, range_dir_t dir); // 'range/'reverse range attribute ExpRange(ExpName*base, bool reverse_range); - ~ExpRange(); + ~ExpRange() override; - Expression*clone() const; + Expression*clone() const override; // Returns the upper boundary Expression*msb(); @@ -1061,10 +1061,10 @@ class ExpRange : public Expression { range_dir_t direction() const { return direction_; } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; private: // Regular range related fields Expression*left_, *right_; @@ -1083,15 +1083,15 @@ class ExpRange : public Expression { class ExpDelay : public Expression { public: ExpDelay(Expression*expr, Expression*delay); - ~ExpDelay(); + ~ExpDelay() override; - Expression*clone() const { return new ExpDelay(expr_->clone(), delay_->clone()); } + Expression*clone() const override { return new ExpDelay(expr_->clone(), delay_->clone()); } - int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); - void write_to_stream(std::ostream&) const; - int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const; - void dump(std::ostream&out, int indent = 0) const; - void visit(ExprVisitor& func); + int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override; + void write_to_stream(std::ostream&) const override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) const override; + void dump(std::ostream&out, int indent = 0) const override; + void visit(ExprVisitor& func) override; const Expression*peek_expr() const { return expr_; } const Expression*peek_delay() const { return delay_; } diff --git a/vhdlpp/package.cc b/vhdlpp/package.cc index 5e92a4b59..2812e54ac 100644 --- a/vhdlpp/package.cc +++ b/vhdlpp/package.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -51,10 +51,10 @@ int Package::elaborate() for (map::iterator cur = cur_subprograms_.begin() ; cur != cur_subprograms_.end() ; ++ cur) { - SubHeaderList& subp_list = cur->second; + const SubHeaderList& subp_list = cur->second; - for(SubHeaderList::iterator it = subp_list.begin(); - it != subp_list.end(); ++it) { + for(SubHeaderList::const_iterator it = subp_list.cbegin(); + it != subp_list.cend(); ++it) { (*it)->set_package(this); errors += (*it)->elaborate(); } diff --git a/vhdlpp/package.h b/vhdlpp/package.h index 7ae45120a..48fef25ae 100644 --- a/vhdlpp/package.h +++ b/vhdlpp/package.h @@ -1,7 +1,7 @@ #ifndef IVL_package_H #define IVL_package_H /* - * Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -28,7 +28,7 @@ class Package : public Scope, public LineInfo { public: Package(perm_string name, const ActiveScope&ref); - ~Package(); + ~Package() override; // The the library from which this package came. Having a // source library influences the emit_package() method. diff --git a/vhdlpp/scope.h b/vhdlpp/scope.h index 43752e9f0..02b9ea7f1 100644 --- a/vhdlpp/scope.h +++ b/vhdlpp/scope.h @@ -1,7 +1,7 @@ #ifndef IVL_scope_H #define IVL_scope_H /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -180,7 +180,7 @@ class Scope : public ScopeBase { public: explicit Scope(const ActiveScope&ref) : ScopeBase(ref) {} - virtual ~Scope() {} + virtual ~Scope() override {} ComponentBase* find_component(perm_string by_name); @@ -202,7 +202,7 @@ class ActiveScope : public ScopeBase { ActiveScope() : context_entity_(0) { } explicit ActiveScope(const ActiveScope*par); - ~ActiveScope() { } + ~ActiveScope() override { } // Pull items from "that" scope into "this" scope as is // defined by a "use" directive. The parser uses this method diff --git a/vhdlpp/sequential.h b/vhdlpp/sequential.h index f809e6f0a..712e0f96c 100644 --- a/vhdlpp/sequential.h +++ b/vhdlpp/sequential.h @@ -1,7 +1,7 @@ #ifndef IVL_sequential_H #define IVL_sequential_H /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -38,7 +38,7 @@ class SequentialStmt : public LineInfo { public: SequentialStmt(); - virtual ~SequentialStmt() =0; + virtual ~SequentialStmt() override =0; public: virtual int elaborate(Entity*ent, ScopeBase*scope); @@ -57,12 +57,12 @@ class SequentialStmt : public LineInfo { class LoopStatement : public SequentialStmt { public: LoopStatement(perm_string block_name, std::list*); - virtual ~LoopStatement(); + virtual ~LoopStatement() override; inline perm_string loop_name() const { return name_; } - void dump(std::ostream&out, int indent) const; - void visit(SeqStmtVisitor& func); + void dump(std::ostream&out, int indent) const override; + void visit(SeqStmtVisitor& func) override; protected: int elaborate_substatements(Entity*ent, ScopeBase*scope); @@ -104,14 +104,14 @@ class IfSequential : public SequentialStmt { IfSequential(Expression*cond, std::list*tr, std::list*elsif, std::list*fa); - ~IfSequential(); + ~IfSequential() override; public: - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; - void visit(SeqStmtVisitor& func); + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; + void visit(SeqStmtVisitor& func) override; const Expression*peek_condition() const { return cond_; } @@ -132,13 +132,13 @@ class IfSequential : public SequentialStmt { class ReturnStmt : public SequentialStmt { public: explicit ReturnStmt(Expression*val); - ~ReturnStmt(); + ~ReturnStmt() override; public: - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; const Expression*peek_expr() const { return val_; }; void cast_to(const VType*type); @@ -150,13 +150,13 @@ class ReturnStmt : public SequentialStmt { class SignalSeqAssignment : public SequentialStmt { public: SignalSeqAssignment(Expression*sig, std::list*wav); - ~SignalSeqAssignment(); + ~SignalSeqAssignment() override; public: - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; private: Expression*lval_; @@ -186,14 +186,14 @@ class CaseSeqStmt : public SequentialStmt { public: CaseSeqStmt(Expression*cond, std::list*sp); - ~CaseSeqStmt(); + ~CaseSeqStmt() override; public: - void dump(std::ostream&out, int indent) const; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void visit(SeqStmtVisitor& func); + void dump(std::ostream&out, int indent) const override; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void visit(SeqStmtVisitor& func) override; private: Expression* cond_; @@ -205,11 +205,11 @@ class ProcedureCall : public SequentialStmt { explicit ProcedureCall(perm_string name); ProcedureCall(perm_string name, std::list* param_list); ProcedureCall(perm_string name, std::list* param_list); - ~ProcedureCall(); + ~ProcedureCall() override; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void dump(std::ostream&out, int indent) const override; private: perm_string name_; @@ -220,13 +220,13 @@ class ProcedureCall : public SequentialStmt { class VariableSeqAssignment : public SequentialStmt { public: VariableSeqAssignment(Expression*sig, Expression*rval); - ~VariableSeqAssignment(); + ~VariableSeqAssignment() override; public: - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; private: Expression*lval_; @@ -237,12 +237,12 @@ class WhileLoopStatement : public LoopStatement { public: WhileLoopStatement(perm_string loop_name, Expression*, std::list*); - ~WhileLoopStatement(); + ~WhileLoopStatement() override; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*ent, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; private: Expression* cond_; @@ -252,12 +252,12 @@ class ForLoopStatement : public LoopStatement { public: ForLoopStatement(perm_string loop_name, perm_string index, ExpRange*, std::list*); - ~ForLoopStatement(); + ~ForLoopStatement() override; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*ent, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; private: // Emits for-loop which direction is determined at run-time. @@ -271,12 +271,12 @@ class ForLoopStatement : public LoopStatement { class BasicLoopStatement : public LoopStatement { public: BasicLoopStatement(perm_string lname, std::list*); - ~BasicLoopStatement(); + ~BasicLoopStatement() override; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*ent, ScopeBase*scope); - void write_to_stream(std::ostream&fd); - void dump(std::ostream&out, int indent) const; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*ent, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; + void dump(std::ostream&out, int indent) const override; }; class ReportStmt : public SequentialStmt { @@ -284,12 +284,12 @@ class ReportStmt : public SequentialStmt { typedef enum { UNSPECIFIED, NOTE, WARNING, ERROR, FAILURE } severity_t; ReportStmt(Expression*message, severity_t severity); - virtual ~ReportStmt() {} + virtual ~ReportStmt() override {} - void dump(std::ostream&out, int indent) const; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); + void dump(std::ostream&out, int indent) const override; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; inline Expression*message() const { return msg_; } inline severity_t severity() const { return severity_; } @@ -306,10 +306,10 @@ class AssertStmt : public ReportStmt { AssertStmt(Expression*condition, Expression*message, ReportStmt::severity_t severity = ReportStmt::ERROR); - void dump(std::ostream&out, int indent) const; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); + void dump(std::ostream&out, int indent) const override; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; private: Expression*cond_; @@ -322,10 +322,10 @@ class WaitForStmt : public SequentialStmt { public: explicit WaitForStmt(Expression*delay); - void dump(std::ostream&out, int indent) const; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); + void dump(std::ostream&out, int indent) const override; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; private: Expression*delay_; @@ -336,10 +336,10 @@ class WaitStmt : public SequentialStmt { typedef enum { ON, UNTIL, FINAL } wait_type_t; WaitStmt(wait_type_t typ, Expression*expression); - void dump(std::ostream&out, int indent) const; - int elaborate(Entity*ent, ScopeBase*scope); - int emit(std::ostream&out, Entity*entity, ScopeBase*scope); - void write_to_stream(std::ostream&fd); + void dump(std::ostream&out, int indent) const override; + int elaborate(Entity*ent, ScopeBase*scope) override; + int emit(std::ostream&out, Entity*entity, ScopeBase*scope) override; + void write_to_stream(std::ostream&fd) override; inline wait_type_t type() const { return type_; } diff --git a/vhdlpp/std_funcs.cc b/vhdlpp/std_funcs.cc index f6986989e..bf2bb3205 100644 --- a/vhdlpp/std_funcs.cc +++ b/vhdlpp/std_funcs.cc @@ -1,5 +1,5 @@ /* - * Copyright CERN 2016-2021 + * Copyright CERN 2016-2025 * @author Maciej Suminski (maciej.suminski@cern.ch) * * This source code is free software; you can redistribute it @@ -41,7 +41,7 @@ class SubprogramToInteger : public SubprogramStdHeader { } int emit_name(const std::vector&argv, - std::ostream&out, Entity*ent, ScopeBase*scope) const { + std::ostream&out, Entity*ent, ScopeBase*scope) const override { bool signed_flag = false; // to_integer converts unsigned to natural @@ -74,12 +74,12 @@ class SubprogramSizeCast : public SubprogramStdHeader { } int emit_name(const std::vector&, - std::ostream&, Entity*, ScopeBase*) const { + std::ostream&, Entity*, ScopeBase*) const override { return 0; } int emit_args(const std::vector&argv, - std::ostream&out, Entity*ent, ScopeBase*scope) const { + std::ostream&out, Entity*ent, ScopeBase*scope) const override { int64_t new_size, old_size; const VType*type = argv[0]->probe_type(ent, scope); @@ -131,7 +131,7 @@ class SubprogramReadWrite : public SubprogramBuiltin { enum format_t { FORMAT_STD, FORMAT_BOOL, FORMAT_TIME, FORMAT_HEX, FORMAT_STRING }; int emit_args(const std::vector&argv, - std::ostream&out, Entity*ent, ScopeBase*scope) const { + std::ostream&out, Entity*ent, ScopeBase*scope) const override { int errors = 0; diff --git a/vhdlpp/subprogram.cc b/vhdlpp/subprogram.cc index fd91f97e2..b608d7720 100644 --- a/vhdlpp/subprogram.cc +++ b/vhdlpp/subprogram.cc @@ -242,7 +242,7 @@ int SubprogramHeader::elaborate_argument(Expression*expr, int idx, return expr->elaborate_expr(ent, scope, type); } -SubprogramHeader*SubprogramHeader::make_instance(std::vector arguments, +SubprogramHeader*SubprogramHeader::make_instance(const std::vector&arguments, ScopeBase*scope) const { assert(arguments.size() == ports_->size()); @@ -288,7 +288,7 @@ SubprogramHeader*SubprogramHeader::make_instance(std::vector argume struct check_return_type : public SeqStmtVisitor { explicit check_return_type(const SubprogramBody*subp) : subp_(subp), ret_type_(NULL) {} - void operator() (SequentialStmt*s) + void operator() (SequentialStmt*s) override { const ReturnStmt*ret; if((ret = dynamic_cast(s))) { diff --git a/vhdlpp/subprogram.h b/vhdlpp/subprogram.h index a032871d5..856c8b3eb 100644 --- a/vhdlpp/subprogram.h +++ b/vhdlpp/subprogram.h @@ -1,7 +1,7 @@ #ifndef IVL_subprogram_H #define IVL_subprogram_H /* - * Copyright (c) 2013-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2013-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * Copyright CERN 2015 * @author Maciej Suminski (maciej.suminski@cern.ch) @@ -38,9 +38,9 @@ class SubprogramBody : public LineInfo, public ScopeBase { public: SubprogramBody(); - ~SubprogramBody(); + ~SubprogramBody() override; - const InterfacePort*find_param(perm_string nam) const; + const InterfacePort*find_param(perm_string nam) const override; void set_statements(std::list*statements); inline bool empty_statements() const { return !statements_ || statements_->empty(); } @@ -55,7 +55,7 @@ class SubprogramBody : public LineInfo, public ScopeBase { void dump(std::ostream&fd) const; const SubprogramHeader*header() const { return header_; } - bool is_subprogram() const { return true; } + bool is_subprogram() const override { return true; } private: std::list*statements_; @@ -68,7 +68,7 @@ class SubprogramHeader : public LineInfo { public: SubprogramHeader(perm_string name, std::list*ports, const VType*return_type); - virtual ~SubprogramHeader(); + virtual ~SubprogramHeader() override; // Return true if the specification (name, types, ports) // matches this subprogram and that subprogram. @@ -124,7 +124,7 @@ class SubprogramHeader : public LineInfo { // a different type. It is used to allow VHDL functions that work with // unbounded std_logic_vectors, so there can be a separate instance // for limited length logic vector. - SubprogramHeader*make_instance(std::vector arguments, ScopeBase*scope) const; + SubprogramHeader*make_instance(const std::vector&arguments, ScopeBase*scope) const; // Emit header as it would show up in a package. int emit_package(std::ostream&fd) const; @@ -154,9 +154,9 @@ class SubprogramStdHeader : public SubprogramHeader SubprogramStdHeader(perm_string nam, std::list*ports, const VType*return_type) : SubprogramHeader(nam, ports, return_type) {} - virtual ~SubprogramStdHeader() {}; + virtual ~SubprogramStdHeader() override {}; - bool is_std() const { return true; } + bool is_std() const override { return true; } }; // The simplest case, when only function name has to be changed. @@ -166,9 +166,9 @@ class SubprogramBuiltin : public SubprogramStdHeader SubprogramBuiltin(perm_string vhdl_name, perm_string sv_name, std::list*ports, const VType*return_type) : SubprogramStdHeader(vhdl_name, ports, return_type), sv_name_(sv_name) {} - ~SubprogramBuiltin() {} + ~SubprogramBuiltin() override {} - int emit_name(const std::vector&, std::ostream&out, Entity*, ScopeBase*) const; + int emit_name(const std::vector&, std::ostream&out, Entity*, ScopeBase*) const override; private: // SystemVerilog counterpart function name diff --git a/vhdlpp/vsignal.h b/vhdlpp/vsignal.h index 850e7dd42..6e5bd7c66 100644 --- a/vhdlpp/vsignal.h +++ b/vhdlpp/vsignal.h @@ -1,7 +1,7 @@ #ifndef IVL_vsignal_H #define IVL_vsignal_H /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-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 @@ -32,7 +32,7 @@ class SigVarBase : public LineInfo { public: SigVarBase(perm_string name, const VType*type, Expression*init_expr); - virtual ~SigVarBase(); + virtual ~SigVarBase() override; const VType* peek_type(void) const { return type_; } diff --git a/vhdlpp/vtype.h b/vhdlpp/vtype.h index bb3c2c910..33f9f7b8c 100644 --- a/vhdlpp/vtype.h +++ b/vhdlpp/vtype.h @@ -1,7 +1,7 @@ #ifndef IVL_vtype_H #define IVL_vtype_H /* - * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2025 Stephen Williams (steve@icarus.com) * Copyright CERN 2014 / Stephen Williams (steve@icarus.com), * @author Maciej Suminski (maciej.suminski@cern.ch) * @@ -145,10 +145,10 @@ extern void preload_global_types(void); * This type is a placeholder for ERROR types. */ class VTypeERROR : public VType { - VType*clone() const { return NULL; } + VType*clone() const override { return NULL; } public: - int emit_def(std::ostream&out, perm_string name) const; + int emit_def(std::ostream&out, perm_string name) const override; }; /* @@ -162,21 +162,21 @@ class VTypePrimitive : public VType { public: explicit VTypePrimitive(type_t tt, bool packed = false); - ~VTypePrimitive(); + ~VTypePrimitive() override; - VType*clone() const { return new VTypePrimitive(*this); } + VType*clone() const override { return new VTypePrimitive(*this); } - bool type_match(const VType*that) const; - void write_to_stream(std::ostream&fd) const; - void show(std::ostream&) const; - int get_width(ScopeBase*scope) const; + bool type_match(const VType*that) const override; + void write_to_stream(std::ostream&fd) const override; + void show(std::ostream&) const override; + int get_width(ScopeBase*scope) const override; type_t type() const { return type_; } int emit_primitive_type(std::ostream&fd) const; - int emit_def(std::ostream&out, perm_string name) const; + int emit_def(std::ostream&out, perm_string name) const override; - bool can_be_packed() const { return packed_; } + bool can_be_packed() const override { return packed_; } private: type_t type_; @@ -215,16 +215,16 @@ class VTypeArray : public VType { VTypeArray(const VType*etype, const std::vector&r, bool signed_vector = false); VTypeArray(const VType*etype, std::list*r, bool signed_vector = false); VTypeArray(const VType*etype, int msb, int lsb, bool signed_vector = false); - ~VTypeArray(); + ~VTypeArray() override; - VType*clone() const; + VType*clone() const override; - int elaborate(Entity*ent, ScopeBase*scope) const; - bool type_match(const VType*that) const; - void write_to_stream(std::ostream&fd) const; - void write_type_to_stream(std::ostream&fd) const; - void show(std::ostream&) const; - int get_width(ScopeBase*scope) const; + int elaborate(Entity*ent, ScopeBase*scope) const override; + bool type_match(const VType*that) const override; + void write_to_stream(std::ostream&fd) const override; + void write_type_to_stream(std::ostream&fd) const override; + void show(std::ostream&) const override; + int get_width(ScopeBase*scope) const override; const std::vector&dimensions() const { return ranges_; }; const range_t&dimension(size_t idx) const @@ -241,14 +241,14 @@ class VTypeArray : public VType { // it be unfolded const VType* basic_type(bool typedef_allowed = true) const; - int emit_def(std::ostream&out, perm_string name) const; - int emit_typedef(std::ostream&out, typedef_context_t&ctx) const; + int emit_def(std::ostream&out, perm_string name) const override; + int emit_typedef(std::ostream&out, typedef_context_t&ctx) const override; - bool can_be_packed() const { return etype_->can_be_packed(); } + bool can_be_packed() const override { return etype_->can_be_packed(); } - bool is_unbounded() const; + bool is_unbounded() const override; - bool is_variable_length(ScopeBase*scope) const; + bool is_variable_length(ScopeBase*scope) const override; // To handle subtypes inline void set_parent_type(const VTypeArray*parent) { parent_ = parent; } @@ -276,11 +276,11 @@ class VTypeRange : public VType { public: VTypeRange(const VType*base); - virtual ~VTypeRange() = 0; + virtual ~VTypeRange() override = 0; bool write_std_types(std::ostream&fd) const; - int emit_def(std::ostream&out, perm_string name) const; - bool type_match(const VType*that) const; + int emit_def(std::ostream&out, perm_string name) const override; + bool type_match(const VType*that) const override; // Get the type that is limited by the range. inline const VType*base_type() const { return base_; } @@ -294,14 +294,14 @@ class VTypeRangeConst : public VTypeRange { public: VTypeRangeConst(const VType*base, int64_t end, int64_t start); - VType*clone() const { + VType*clone() const override { return new VTypeRangeConst(base_type()->clone(), start_, end_); } int64_t start() const { return start_; } int64_t end() const { return end_; } - void write_to_stream(std::ostream&fd) const; + void write_to_stream(std::ostream&fd) const override; private: const int64_t start_, end_; @@ -311,13 +311,13 @@ class VTypeRangeExpr : public VTypeRange { public: VTypeRangeExpr(const VType*base, Expression*end, Expression*start, bool downto); - ~VTypeRangeExpr(); + ~VTypeRangeExpr() override; - VType*clone() const; - int elaborate(Entity*end, ScopeBase*scope) const; + VType*clone() const override; + int elaborate(Entity*end, ScopeBase*scope) const override; public: // Virtual methods - void write_to_stream(std::ostream&fd) const; + void write_to_stream(std::ostream&fd) const override; private: // Boundaries @@ -331,16 +331,16 @@ class VTypeEnum : public VType { public: explicit VTypeEnum(const std::list*names); - ~VTypeEnum(); + ~VTypeEnum() override; - VType*clone() const { return new VTypeEnum(*this); } + VType*clone() const override { return new VTypeEnum(*this); } - void write_to_stream(std::ostream&fd) const; - void show(std::ostream&) const; - int get_width(ScopeBase*) const { return 32; } + void write_to_stream(std::ostream&fd) const override; + void show(std::ostream&) const override; + int get_width(ScopeBase*) const override { return 32; } - int emit_def(std::ostream&out, perm_string name) const; - int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const; + int emit_def(std::ostream&out, perm_string name) const override; + int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const override; // Checks if the name is stored in the enum. bool has_name(perm_string name) const; @@ -372,16 +372,16 @@ class VTypeRecord : public VType { public: explicit VTypeRecord(std::list*elements); - ~VTypeRecord(); + ~VTypeRecord() override; - VType*clone() const { return new VTypeRecord(*this); } + VType*clone() const override { return new VTypeRecord(*this); } - void write_to_stream(std::ostream&fd) const; - void show(std::ostream&) const; - int get_width(ScopeBase*scope) const; - int emit_def(std::ostream&out, perm_string name) const; + void write_to_stream(std::ostream&fd) const override; + void show(std::ostream&) const override; + int get_width(ScopeBase*scope) const override; + int emit_def(std::ostream&out, perm_string name) const override; - bool can_be_packed() const { return true; } + bool can_be_packed() const override { return true; } const element_t* element_by_name(perm_string name, int*index = NULL) const; inline const std::vector get_elements() const { return elements_; } @@ -394,11 +394,11 @@ class VTypeDef : public VType { public: explicit VTypeDef(perm_string name); explicit VTypeDef(perm_string name, const VType*is); - virtual ~VTypeDef(); + virtual ~VTypeDef() override; - VType*clone() const { return new VTypeDef(*this); } + VType*clone() const override { return new VTypeDef(*this); } - bool type_match(const VType*that) const; + bool type_match(const VType*that) const override; inline perm_string peek_name() const { return name_; } @@ -410,17 +410,17 @@ class VTypeDef : public VType { // type, and this method gets it for us. inline const VType* peek_definition(void) const { return type_; } - virtual void write_to_stream(std::ostream&fd) const; - void write_type_to_stream(std::ostream&fd) const; - int get_width(ScopeBase*scope) const { return type_->get_width(scope); } - int emit_typedef(std::ostream&out, typedef_context_t&ctx) const; + virtual void write_to_stream(std::ostream&fd) const override; + void write_type_to_stream(std::ostream&fd) const override; + int get_width(ScopeBase*scope) const override { return type_->get_width(scope); } + int emit_typedef(std::ostream&out, typedef_context_t&ctx) const override; - int emit_def(std::ostream&out, perm_string name) const; - int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const; + int emit_def(std::ostream&out, perm_string name) const override; + int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const override; - bool can_be_packed() const { return type_->can_be_packed(); } + bool can_be_packed() const override { return type_->can_be_packed(); } - bool is_unbounded() const { return type_->is_unbounded(); } + bool is_unbounded() const override { return type_->is_unbounded(); } protected: perm_string name_; @@ -431,7 +431,7 @@ class VSubTypeDef : public VTypeDef { public: explicit VSubTypeDef(perm_string name) : VTypeDef(name) {} explicit VSubTypeDef(perm_string name, const VType*is) : VTypeDef(name, is) {} - void write_typedef_to_stream(std::ostream&fd, perm_string name) const; + void write_typedef_to_stream(std::ostream&fd, perm_string name) const override; }; #endif /* IVL_vtype_H */