Internals: Cleanup some constructors. No functional change intended.

This commit is contained in:
Wilson Snyder 2022-09-15 08:54:04 -04:00
parent da20da264b
commit d74536a4dc
5 changed files with 41 additions and 54 deletions

View File

@ -985,6 +985,7 @@ public:
enum en : uint8_t { HIGHZ, SMALL, MEDIUM, WEAK, LARGE, PULL, STRONG, SUPPLY }; enum en : uint8_t { HIGHZ, SMALL, MEDIUM, WEAK, LARGE, PULL, STRONG, SUPPLY };
enum en m_e; enum en m_e;
// cppcheck-suppress noExplicitConstructor
inline VStrength(en strengthLevel) inline VStrength(en strengthLevel)
: m_e(strengthLevel) {} : m_e(strengthLevel) {}
explicit inline VStrength(int _e) explicit inline VStrength(int _e)

View File

@ -35,22 +35,19 @@ class AstNodeDType VL_NOT_FINAL : public AstNode {
// but it's currently so prevalent in the code we leave it here. // but it's currently so prevalent in the code we leave it here.
// Note the below members are included in AstTypeTable::Key lookups // Note the below members are included in AstTypeTable::Key lookups
private: private:
int m_width; // (also in AstTypeTable::Key) Bit width of operation int m_width = 0; // (also in AstTypeTable::Key) Bit width of operation
int m_widthMin; // (also in AstTypeTable::Key) If unsized, bitwidth of minimum implementation int m_widthMin
= 0; // (also in AstTypeTable::Key) If unsized, bitwidth of minimum implementation
VSigning m_numeric; // (also in AstTypeTable::Key) Node is signed VSigning m_numeric; // (also in AstTypeTable::Key) Node is signed
// Other members // Other members
bool m_generic; // Simple globally referenced type, don't garbage collect bool m_generic = false; // Simple globally referenced type, don't garbage collect
// Unique number assigned to each dtype during creation for IEEE matching // Unique number assigned to each dtype during creation for IEEE matching
static int s_uniqueNum; static int s_uniqueNum;
protected: protected:
// CONSTRUCTORS // CONSTRUCTORS
AstNodeDType(VNType t, FileLine* fl) AstNodeDType(VNType t, FileLine* fl)
: AstNode{t, fl} { : AstNode{t, fl} {}
m_width = 0;
m_widthMin = 0;
m_generic = false;
}
public: public:
ASTNODE_BASE_FUNCS(NodeDType) ASTNODE_BASE_FUNCS(NodeDType)
@ -204,7 +201,7 @@ private:
// MEMBERS // MEMBERS
string m_name; // Name from upper typedef, if any string m_name; // Name from upper typedef, if any
bool m_packed; bool m_packed;
bool m_isFourstate; bool m_isFourstate = false; // V3Width computes
MemberNameMap m_members; MemberNameMap m_members;
const int m_uniqueNum; const int m_uniqueNum;
@ -214,7 +211,6 @@ protected:
, m_uniqueNum{uniqueNumInc()} { , m_uniqueNum{uniqueNumInc()} {
// VSigning::NOSIGN overloaded to indicate not packed // VSigning::NOSIGN overloaded to indicate not packed
m_packed = (numericUnpack != VSigning::NOSIGN); m_packed = (numericUnpack != VSigning::NOSIGN);
m_isFourstate = false; // V3Width computes
numeric(VSigning::fromBool(numericUnpack.isSigned())); numeric(VSigning::fromBool(numericUnpack.isSigned()));
} }

View File

@ -1117,7 +1117,7 @@ public:
} }
AstRand(FileLine* fl, AstNode* seedp, bool urandom) AstRand(FileLine* fl, AstNode* seedp, bool urandom)
: ASTGEN_SUPER_Rand(fl) : ASTGEN_SUPER_Rand(fl)
, m_urandom(urandom) { , m_urandom{urandom} {
setNOp1p(seedp); setNOp1p(seedp);
} }
ASTNODE_NODE_FUNCS(Rand) ASTNODE_NODE_FUNCS(Rand)

View File

@ -191,9 +191,8 @@ private:
string m_name; ///< Filename string m_name; ///< Filename
public: public:
AstNodeFile(VNType t, FileLine* fl, const string& name) AstNodeFile(VNType t, FileLine* fl, const string& name)
: AstNode(t, fl) { : AstNode(t, fl)
m_name = name; , m_name{name} {}
}
ASTNODE_BASE_FUNCS(NodeFile) ASTNODE_BASE_FUNCS(NodeFile)
virtual void dump(std::ostream& str) const override; virtual void dump(std::ostream& str) const override;
virtual string name() const override { return m_name; } virtual string name() const override { return m_name; }
@ -599,10 +598,9 @@ private:
protected: protected:
// Node that puts text into the output stream // Node that puts text into the output stream
AstNodeText(VNType t, FileLine* fl, const string& textp) AstNodeText(VNType t, FileLine* fl, const string& text)
: AstNode{t, fl} { : AstNode{t, fl}
m_text = textp; // Copy it , m_text{text} {}
}
public: public:
ASTNODE_BASE_FUNCS(NodeText) ASTNODE_BASE_FUNCS(NodeText)
@ -638,10 +636,10 @@ private:
public: public:
AstActive(FileLine* fl, const string& name, AstSenTree* sensesp) AstActive(FileLine* fl, const string& name, AstSenTree* sensesp)
: ASTGEN_SUPER_Active(fl) { : ASTGEN_SUPER_Active(fl)
m_name = name; // Copy it , m_name{name}
, m_sensesp{sensesp} {
UASSERT(sensesp, "Sensesp required arg"); UASSERT(sensesp, "Sensesp required arg");
m_sensesp = sensesp;
} }
ASTNODE_NODE_FUNCS(Active) ASTNODE_NODE_FUNCS(Active)
virtual void dump(std::ostream& str = std::cout) const override; virtual void dump(std::ostream& str = std::cout) const override;
@ -1197,10 +1195,10 @@ private:
string m_path; // Dotted cellname to set parameter of string m_path; // Dotted cellname to set parameter of
public: public:
AstDefParam(FileLine* fl, const string& path, const string& name, AstNode* rhsp) AstDefParam(FileLine* fl, const string& path, const string& name, AstNode* rhsp)
: ASTGEN_SUPER_DefParam(fl) { : ASTGEN_SUPER_DefParam(fl)
, m_name{name}
, m_path{path} {
setOp1p(rhsp); setOp1p(rhsp);
m_name = name;
m_path = path;
} }
virtual string name() const override { return m_name; } // * = Scope name virtual string name() const override { return m_name; } // * = Scope name
ASTNODE_NODE_FUNCS(DefParam) ASTNODE_NODE_FUNCS(DefParam)
@ -1714,9 +1712,9 @@ private:
public: public:
AstPull(FileLine* fl, AstNode* lhsp, bool direction) AstPull(FileLine* fl, AstNode* lhsp, bool direction)
: ASTGEN_SUPER_Pull(fl) { : ASTGEN_SUPER_Pull(fl)
, m_direction{direction} {
setOp1p(lhsp); setOp1p(lhsp);
m_direction = direction;
} }
ASTNODE_NODE_FUNCS(Pull) ASTNODE_NODE_FUNCS(Pull)
virtual bool same(const AstNode* samep) const override { virtual bool same(const AstNode* samep) const override {
@ -1996,7 +1994,7 @@ public:
class AstTypedef final : public AstNode { class AstTypedef final : public AstNode {
private: private:
string m_name; string m_name;
bool m_attrPublic; bool m_attrPublic = false;
string m_tag; // Holds the string of the verilator tag -- used in XML output. string m_tag; // Holds the string of the verilator tag -- used in XML output.
public: public:
AstTypedef(FileLine* fl, const string& name, AstNode* attrsp, VFlagChildDType, AstTypedef(FileLine* fl, const string& name, AstNode* attrsp, VFlagChildDType,
@ -2006,7 +2004,6 @@ public:
childDTypep(dtp); // Only for parser childDTypep(dtp); // Only for parser
addAttrsp(attrsp); addAttrsp(attrsp);
dtypep(nullptr); // V3Width will resolve dtypep(nullptr); // V3Width will resolve
m_attrPublic = false;
} }
ASTNODE_NODE_FUNCS(Typedef) ASTNODE_NODE_FUNCS(Typedef)
virtual void dump(std::ostream& str) const override; virtual void dump(std::ostream& str) const override;
@ -3045,25 +3042,22 @@ class AstCoverDecl final : public AstNodeStmt {
// Parents: {statement list} // Parents: {statement list}
// Children: none // Children: none
private: private:
AstCoverDecl* m_dataDeclp; // [After V3CoverageJoin] Pointer to duplicate declaration to get AstCoverDecl* m_dataDeclp = nullptr; // [After V3CoverageJoin] Pointer to duplicate
// data from instead // declaration to get data from instead
string m_page; string m_page;
string m_text; string m_text;
string m_hier; string m_hier;
string m_linescov; string m_linescov;
int m_offset; // Offset column numbers to uniq-ify IFs int m_offset; // Offset column numbers to uniq-ify IFs
int m_binNum; // Set by V3EmitCSyms to tell final V3Emit what to increment int m_binNum = 0; // Set by V3EmitCSyms to tell final V3Emit what to increment
public: public:
AstCoverDecl(FileLine* fl, const string& page, const string& comment, const string& linescov, AstCoverDecl(FileLine* fl, const string& page, const string& comment, const string& linescov,
int offset) int offset)
: ASTGEN_SUPER_CoverDecl(fl) { : ASTGEN_SUPER_CoverDecl(fl)
m_page = page; , m_page{page}
m_text = comment; , m_text{comment}
m_linescov = linescov; , m_linescov{linescov}
m_offset = offset; , m_offset{offset} {}
m_binNum = 0;
m_dataDeclp = nullptr;
}
ASTNODE_NODE_FUNCS(CoverDecl) ASTNODE_NODE_FUNCS(CoverDecl)
virtual const char* broken() const override { virtual const char* broken() const override {
BROKEN_RTN(m_dataDeclp && !m_dataDeclp->brokeExists()); BROKEN_RTN(m_dataDeclp && !m_dataDeclp->brokeExists());
@ -3200,17 +3194,17 @@ private:
public: public:
AstDisplay(FileLine* fl, VDisplayType dispType, const string& text, AstNode* filep, AstDisplay(FileLine* fl, VDisplayType dispType, const string& text, AstNode* filep,
AstNode* exprsp, char missingArgChar = 'd') AstNode* exprsp, char missingArgChar = 'd')
: ASTGEN_SUPER_Display(fl) { : ASTGEN_SUPER_Display(fl)
setOp1p(new AstSFormatF(fl, text, true, exprsp, missingArgChar)); , m_displayType{dispType} {
setOp1p(new AstSFormatF{fl, text, true, exprsp, missingArgChar});
setNOp3p(filep); setNOp3p(filep);
m_displayType = dispType;
} }
AstDisplay(FileLine* fl, VDisplayType dispType, AstNode* filep, AstNode* exprsp, AstDisplay(FileLine* fl, VDisplayType dispType, AstNode* filep, AstNode* exprsp,
char missingArgChar = 'd') char missingArgChar = 'd')
: ASTGEN_SUPER_Display(fl) { : ASTGEN_SUPER_Display(fl)
setOp1p(new AstSFormatF(fl, AstSFormatF::NoFormat(), exprsp, missingArgChar)); , m_displayType{dispType} {
setOp1p(new AstSFormatF{fl, AstSFormatF::NoFormat(), exprsp, missingArgChar});
setNOp3p(filep); setNOp3p(filep);
m_displayType = dispType;
} }
ASTNODE_NODE_FUNCS(Display) ASTNODE_NODE_FUNCS(Display)
virtual void dump(std::ostream& str) const override; virtual void dump(std::ostream& str) const override;
@ -4246,16 +4240,12 @@ public:
}; };
class AstIf final : public AstNodeIf { class AstIf final : public AstNodeIf {
private: private:
bool m_uniquePragma; // unique case bool m_uniquePragma = false; // unique case
bool m_unique0Pragma; // unique0 case bool m_unique0Pragma = false; // unique0 case
bool m_priorityPragma; // priority case bool m_priorityPragma = false; // priority case
public: public:
AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp = nullptr, AstNode* elsesp = nullptr) AstIf(FileLine* fl, AstNode* condp, AstNode* ifsp = nullptr, AstNode* elsesp = nullptr)
: ASTGEN_SUPER_If(fl, condp, ifsp, elsesp) { : ASTGEN_SUPER_If(fl, condp, ifsp, elsesp) {}
m_uniquePragma = false;
m_unique0Pragma = false;
m_priorityPragma = false;
}
ASTNODE_NODE_FUNCS(If) ASTNODE_NODE_FUNCS(If)
bool uniquePragma() const { return m_uniquePragma; } bool uniquePragma() const { return m_uniquePragma; }
void uniquePragma(bool flag) { m_uniquePragma = flag; } void uniquePragma(bool flag) { m_uniquePragma = flag; }

View File

@ -716,7 +716,7 @@ int main(int argc, char** argv, char** /*env*/) {
// Command option parsing // Command option parsing
v3Global.opt.bin(argv[0]); v3Global.opt.bin(argv[0]);
const string argString = V3Options::argString(argc - 1, argv + 1); const string argString = V3Options::argString(argc - 1, argv + 1);
v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename()), argc - 1, argv + 1); v3Global.opt.parseOpts(new FileLine{FileLine::commandLineFilename()}, argc - 1, argv + 1);
// Validate settings (aka Boost.Program_options) // Validate settings (aka Boost.Program_options)
v3Global.opt.notify(); v3Global.opt.notify();