Internals: Fix constructor style.

This commit is contained in:
Wilson Snyder 2022-11-19 14:45:33 -05:00
parent d0e7177d8e
commit 21d80cdfa1
19 changed files with 78 additions and 78 deletions

View File

@ -95,8 +95,8 @@ private:
m_unnamedScope = dot(m_unnamedScope, ident); m_unnamedScope = dot(m_unnamedScope, ident);
// Create CellInline for dotted var resolution // Create CellInline for dotted var resolution
if (!m_ftaskp) { if (!m_ftaskp) {
AstCellInline* const inlinep = new AstCellInline( AstCellInline* const inlinep = new AstCellInline{
nodep->fileline(), m_unnamedScope, blockName, m_modp->timeunit()); nodep->fileline(), m_unnamedScope, blockName, m_modp->timeunit()};
m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells
} }
} }

View File

@ -355,8 +355,8 @@ void V3Broken::brokenAll(AstNetlist* nodep) {
void V3Broken::selfTest() { void V3Broken::selfTest() {
// Exercise addNewed and deleted for coverage, as otherwise only used with VL_LEAK_CHECKS // Exercise addNewed and deleted for coverage, as otherwise only used with VL_LEAK_CHECKS
FileLine* const fl = new FileLine(FileLine::commandLineFilename()); FileLine* const fl = new FileLine{FileLine::commandLineFilename()};
const AstNode* const newp = new AstBegin(fl, "[EditWrapper]", nullptr); const AstNode* const newp = new AstBegin{fl, "[EditWrapper]", nullptr};
addNewed(newp); addNewed(newp);
deleted(newp); deleted(newp);
VL_DO_DANGLING(delete newp, newp); VL_DO_DANGLING(delete newp, newp);

View File

@ -58,7 +58,7 @@ private:
UASSERT_OBJ(!nodep->access().isRW(), nodep, "Cannot handle a READWRITE reference"); UASSERT_OBJ(!nodep->access().isRW(), nodep, "Cannot handle a READWRITE reference");
if (nodep->access().isWriteOnly()) { if (nodep->access().isWriteOnly()) {
nodep->replaceWith( nodep->replaceWith(
new AstVarRef(nodep->fileline(), nodep->varScopep(), VAccess::READ)); new AstVarRef{nodep->fileline(), nodep->varScopep(), VAccess::READ});
} }
} }
@ -113,7 +113,7 @@ private:
AstIf* makeActiveIf(AstSenTree* sensesp) { AstIf* makeActiveIf(AstSenTree* sensesp) {
AstNode* const senEqnp = createSenseEquation(sensesp->sensesp()); AstNode* const senEqnp = createSenseEquation(sensesp->sensesp());
UASSERT_OBJ(senEqnp, sensesp, "No sense equation, shouldn't be in sequent activation."); UASSERT_OBJ(senEqnp, sensesp, "No sense equation, shouldn't be in sequent activation.");
AstIf* const newifp = new AstIf(sensesp->fileline(), senEqnp); AstIf* const newifp = new AstIf{sensesp->fileline(), senEqnp};
return newifp; return newifp;
} }
void clearLastSen() { void clearLastSen() {
@ -130,11 +130,11 @@ private:
AstNode* const changeWrp = nodep->changep()->unlinkFrBack(); AstNode* const changeWrp = nodep->changep()->unlinkFrBack();
AstNode* const changeRdp = ConvertWriteRefsToRead::main(changeWrp->cloneTree(false)); AstNode* const changeRdp = ConvertWriteRefsToRead::main(changeWrp->cloneTree(false));
AstIf* const newp AstIf* const newp
= new AstIf(nodep->fileline(), new AstXor(nodep->fileline(), origp, changeRdp), incp); = new AstIf{nodep->fileline(), new AstXor{nodep->fileline(), origp, changeRdp}, incp};
// We could add another IF to detect posedges, and only increment if so. // We could add another IF to detect posedges, and only increment if so.
// It's another whole branch though versus a potential memory miss. // It's another whole branch though versus a potential memory miss.
// We'll go with the miss. // We'll go with the miss.
newp->addThensp(new AstAssign(nodep->fileline(), changeWrp, origp->cloneTree(false))); newp->addThensp(new AstAssign{nodep->fileline(), changeWrp, origp->cloneTree(false)});
nodep->replaceWith(newp); nodep->replaceWith(newp);
VL_DO_DANGLING(nodep->deleteTree(), nodep); VL_DO_DANGLING(nodep->deleteTree(), nodep);
} }

View File

@ -105,10 +105,10 @@ public:
// Apply all attributes to the variable // Apply all attributes to the variable
void apply(AstVar* varp) { void apply(AstVar* varp) {
for (const_iterator it = begin(); it != end(); ++it) { for (const_iterator it = begin(); it != end(); ++it) {
AstNode* const newp = new AstAttrOf(varp->fileline(), it->m_type); AstNode* const newp = new AstAttrOf{varp->fileline(), it->m_type};
varp->addAttrsp(newp); varp->addAttrsp(newp);
if (it->m_type == VAttrType::VAR_PUBLIC_FLAT_RW && it->m_sentreep) { if (it->m_type == VAttrType::VAR_PUBLIC_FLAT_RW && it->m_sentreep) {
newp->addNext(new AstAlwaysPublic(varp->fileline(), it->m_sentreep, nullptr)); newp->addNext(new AstAlwaysPublic{varp->fileline(), it->m_sentreep, nullptr});
} }
} }
} }
@ -143,9 +143,9 @@ public:
void apply(AstNodeFTask* ftaskp) const { void apply(AstNodeFTask* ftaskp) const {
if (m_noinline) if (m_noinline)
ftaskp->addStmtsp(new AstPragma(ftaskp->fileline(), VPragmaType::NO_INLINE_TASK)); ftaskp->addStmtsp(new AstPragma{ftaskp->fileline(), VPragmaType::NO_INLINE_TASK});
if (m_public) if (m_public)
ftaskp->addStmtsp(new AstPragma(ftaskp->fileline(), VPragmaType::PUBLIC_TASK)); ftaskp->addStmtsp(new AstPragma{ftaskp->fileline(), VPragmaType::PUBLIC_TASK});
// Only functions can have isolate (return value) // Only functions can have isolate (return value)
if (VN_IS(ftaskp, Func)) ftaskp->attrIsolateAssign(m_isolate); if (VN_IS(ftaskp, Func)) ftaskp->attrIsolateAssign(m_isolate);
} }
@ -194,7 +194,7 @@ public:
if (m_inline) { if (m_inline) {
const VPragmaType type const VPragmaType type
= m_inlineValue ? VPragmaType::INLINE_MODULE : VPragmaType::NO_INLINE_MODULE; = m_inlineValue ? VPragmaType::INLINE_MODULE : VPragmaType::NO_INLINE_MODULE;
AstNode* const nodep = new AstPragma(modp->fileline(), type); AstNode* const nodep = new AstPragma{modp->fileline(), type};
modp->addStmtsp(nodep); modp->addStmtsp(nodep);
} }
for (const auto& itr : m_modPragmas) { for (const auto& itr : m_modPragmas) {
@ -208,7 +208,7 @@ public:
if (!nodep->unnamed()) { if (!nodep->unnamed()) {
for (const string& i : m_coverageOffBlocks) { for (const string& i : m_coverageOffBlocks) {
if (VString::wildmatch(nodep->name(), i)) { if (VString::wildmatch(nodep->name(), i)) {
nodep->addStmtsp(new AstPragma(nodep->fileline(), pragma)); nodep->addStmtsp(new AstPragma{nodep->fileline(), pragma});
} }
} }
} }
@ -302,7 +302,7 @@ public:
// Apply to block at this line // Apply to block at this line
const VPragmaType pragma = VPragmaType::COVERAGE_BLOCK_OFF; const VPragmaType pragma = VPragmaType::COVERAGE_BLOCK_OFF;
if (lineMatch(nodep->fileline()->lineno(), pragma)) { if (lineMatch(nodep->fileline()->lineno(), pragma)) {
nodep->addStmtsp(new AstPragma(nodep->fileline(), pragma)); nodep->addStmtsp(new AstPragma{nodep->fileline(), pragma});
} }
} }
void applyCase(AstCase* nodep) { void applyCase(AstCase* nodep) {
@ -569,14 +569,14 @@ void V3Config::addVarAttr(FileLine* fl, const string& module, const string& ftas
fl->v3error("Signals inside functions/tasks cannot be marked forceable"); fl->v3error("Signals inside functions/tasks cannot be marked forceable");
} else { } else {
V3ConfigResolver::s().modules().at(module).vars().at(var).push_back( V3ConfigResolver::s().modules().at(module).vars().at(var).push_back(
V3ConfigVarAttr(attr)); V3ConfigVarAttr{attr});
} }
} else { } else {
V3ConfigModule& mod = V3ConfigResolver::s().modules().at(module); V3ConfigModule& mod = V3ConfigResolver::s().modules().at(module);
if (ftask.empty()) { if (ftask.empty()) {
mod.vars().at(var).push_back(V3ConfigVarAttr(attr, sensep)); mod.vars().at(var).push_back(V3ConfigVarAttr{attr, sensep});
} else { } else {
mod.ftasks().at(ftask).vars().at(var).push_back(V3ConfigVarAttr(attr, sensep)); mod.ftasks().at(ftask).vars().at(var).push_back(V3ConfigVarAttr{attr, sensep});
} }
} }
} }

View File

@ -53,14 +53,14 @@ private:
// Create sub function // Create sub function
AstScope* const scopep = m_cfuncp->scopep(); AstScope* const scopep = m_cfuncp->scopep();
const string name = m_cfuncp->name() + "__deep" + cvtToStr(++m_deepNum); const string name = m_cfuncp->name() + "__deep" + cvtToStr(++m_deepNum);
AstCFunc* const funcp = new AstCFunc(nodep->fileline(), name, scopep); AstCFunc* const funcp = new AstCFunc{nodep->fileline(), name, scopep};
funcp->slow(m_cfuncp->slow()); funcp->slow(m_cfuncp->slow());
funcp->isStatic(m_cfuncp->isStatic()); funcp->isStatic(m_cfuncp->isStatic());
funcp->isLoose(m_cfuncp->isLoose()); funcp->isLoose(m_cfuncp->isLoose());
funcp->addStmtsp(nodep); funcp->addStmtsp(nodep);
scopep->addBlocksp(funcp); scopep->addBlocksp(funcp);
// Call sub function at the point where the body was removed from // Call sub function at the point where the body was removed from
AstCCall* const callp = new AstCCall(nodep->fileline(), funcp); AstCCall* const callp = new AstCCall{nodep->fileline(), funcp};
callp->dtypeSetVoid(); callp->dtypeSetVoid();
if (VN_IS(m_modp, Class)) { if (VN_IS(m_modp, Class)) {
funcp->argTypes(EmitCBaseVisitor::symClassVar()); funcp->argTypes(EmitCBaseVisitor::symClassVar());

View File

@ -441,7 +441,7 @@ void V3EmitXml::emitxml() {
const string filename = (v3Global.opt.xmlOutput().empty() const string filename = (v3Global.opt.xmlOutput().empty()
? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".xml" ? v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + ".xml"
: v3Global.opt.xmlOutput()); : v3Global.opt.xmlOutput());
V3OutXmlFile of(filename); V3OutXmlFile of{filename};
of.putsHeader(); of.putsHeader();
of.puts("<!-- DESCR" of.puts("<!-- DESCR"
"IPTION: Verilator output: XML representation of netlist -->\n"); "IPTION: Verilator output: XML representation of netlist -->\n");

View File

@ -52,14 +52,14 @@ void V3Global::readFiles() {
// AstNode::user4p() // VSymEnt* Package and typedef symbol names // AstNode::user4p() // VSymEnt* Package and typedef symbol names
const VNUser4InUse inuser4; const VNUser4InUse inuser4;
VInFilter filter(v3Global.opt.pipeFilter()); VInFilter filter{v3Global.opt.pipeFilter()};
V3ParseSym parseSyms(v3Global.rootp()); // Symbol table must be common across all parsing V3ParseSym parseSyms{v3Global.rootp()}; // Symbol table must be common across all parsing
V3Parse parser(v3Global.rootp(), &filter, &parseSyms); V3Parse parser(v3Global.rootp(), &filter, &parseSyms);
// Read top module // Read top module
const V3StringList& vFiles = v3Global.opt.vFiles(); const V3StringList& vFiles = v3Global.opt.vFiles();
for (const string& filename : vFiles) { for (const string& filename : vFiles) {
parser.parseFile(new FileLine(FileLine::commandLineFilename()), filename, false, parser.parseFile(new FileLine{FileLine::commandLineFilename()}, filename, false,
"Cannot find file containing module: "); "Cannot find file containing module: ");
} }
@ -68,7 +68,7 @@ void V3Global::readFiles() {
// this needs to be done after the top file is read // this needs to be done after the top file is read
const V3StringSet& libraryFiles = v3Global.opt.libraryFiles(); const V3StringSet& libraryFiles = v3Global.opt.libraryFiles();
for (const string& filename : libraryFiles) { for (const string& filename : libraryFiles) {
parser.parseFile(new FileLine(FileLine::commandLineFilename()), filename, true, parser.parseFile(new FileLine{FileLine::commandLineFilename()}, filename, true,
"Cannot find file containing library module: "); "Cannot find file containing library module: ");
} }
// v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("parse.tree")); // v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("parse.tree"));

View File

@ -333,6 +333,6 @@ private:
uint32_t V3InstrCount::count(AstNode* nodep, bool assertNoDups, std::ostream* osp) { uint32_t V3InstrCount::count(AstNode* nodep, bool assertNoDups, std::ostream* osp) {
const InstrCountVisitor visitor{nodep, assertNoDups, osp}; const InstrCountVisitor visitor{nodep, assertNoDups, osp};
if (osp) InstrCountDumpVisitor dumper(nodep, osp); if (osp) InstrCountDumpVisitor dumper{nodep, osp};
return visitor.instrCount(); return visitor.instrCount();
} }

View File

@ -106,7 +106,7 @@ private:
? oldVarp->name() ? oldVarp->name()
: nodep->scopep()->nameDotless() + "__DOT__" + oldVarp->name(); : nodep->scopep()->nameDotless() + "__DOT__" + oldVarp->name();
AstVar* const newVarp AstVar* const newVarp
= new AstVar(oldVarp->fileline(), oldVarp->varType(), newName, oldVarp); = new AstVar{oldVarp->fileline(), oldVarp->varType(), newName, oldVarp};
newVarp->funcLocal(true); newVarp->funcLocal(true);
funcp->addInitsp(newVarp); funcp->addInitsp(newVarp);

View File

@ -1688,7 +1688,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
whole_file += "\n"; // So string match below is simplified whole_file += "\n"; // So string match below is simplified
if (inCmt) fl->v3error("Unterminated /* comment inside -f file."); if (inCmt) fl->v3error("Unterminated /* comment inside -f file.");
fl = new FileLine(filename); fl = new FileLine{filename};
// Split into argument list and process // Split into argument list and process
// Note we try to respect escaped char, double/simple quoted strings // Note we try to respect escaped char, double/simple quoted strings

View File

@ -73,12 +73,12 @@ AstArg* V3ParseGrammar::argWrapList(AstNode* nodep) {
// Convert list of expressions to list of arguments // Convert list of expressions to list of arguments
if (!nodep) return nullptr; if (!nodep) return nullptr;
AstArg* outp = nullptr; AstArg* outp = nullptr;
AstBegin* const tempp = new AstBegin(nodep->fileline(), "[EditWrapper]", nodep); AstBegin* const tempp = new AstBegin{nodep->fileline(), "[EditWrapper]", nodep};
while (nodep) { while (nodep) {
AstNode* const nextp = nodep->nextp(); AstNode* const nextp = nodep->nextp();
AstNode* const exprp = nodep->unlinkFrBack(); AstNode* const exprp = nodep->unlinkFrBack();
nodep = nextp; nodep = nextp;
outp = AstNode::addNext(outp, new AstArg(exprp->fileline(), "", exprp)); outp = AstNode::addNext(outp, new AstArg{exprp->fileline(), "", exprp});
} }
VL_DO_DANGLING(tempp->deleteTree(), tempp); VL_DO_DANGLING(tempp->deleteTree(), tempp);
return outp; return outp;
@ -127,22 +127,22 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra
AstRange* const rangep = VN_CAST(nrangep, Range); AstRange* const rangep = VN_CAST(nrangep, Range);
if (rangep && isPacked) { if (rangep && isPacked) {
arrayp arrayp
= new AstPackArrayDType(rangep->fileline(), VFlagChildDType(), arrayp, rangep); = new AstPackArrayDType{rangep->fileline(), VFlagChildDType(), arrayp, rangep};
} else if (rangep } else if (rangep
&& (VN_IS(rangep->leftp(), Unbounded) && (VN_IS(rangep->leftp(), Unbounded)
|| VN_IS(rangep->rightp(), Unbounded))) { || VN_IS(rangep->rightp(), Unbounded))) {
arrayp = new AstQueueDType(nrangep->fileline(), VFlagChildDType(), arrayp, arrayp = new AstQueueDType{nrangep->fileline(), VFlagChildDType(), arrayp,
rangep->rightp()->cloneTree(true)); rangep->rightp()->cloneTree(true)};
} else if (rangep) { } else if (rangep) {
arrayp = new AstUnpackArrayDType(rangep->fileline(), VFlagChildDType(), arrayp, arrayp = new AstUnpackArrayDType{rangep->fileline(), VFlagChildDType{}, arrayp,
rangep); rangep};
} else if (VN_IS(nrangep, UnsizedRange)) { } else if (VN_IS(nrangep, UnsizedRange)) {
arrayp = new AstUnsizedArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp); arrayp = new AstUnsizedArrayDType{nrangep->fileline(), VFlagChildDType{}, arrayp};
} else if (VN_IS(nrangep, BracketRange)) { } else if (VN_IS(nrangep, BracketRange)) {
const AstBracketRange* const arangep = VN_AS(nrangep, BracketRange); const AstBracketRange* const arangep = VN_AS(nrangep, BracketRange);
AstNode* const keyp = arangep->elementsp()->unlinkFrBack(); AstNode* const keyp = arangep->elementsp()->unlinkFrBack();
arrayp = new AstBracketArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp, arrayp = new AstBracketArrayDType{nrangep->fileline(), VFlagChildDType{}, arrayp,
keyp); keyp};
} else if (VN_IS(nrangep, WildcardRange)) { } else if (VN_IS(nrangep, WildcardRange)) {
arrayp = new AstWildcardArrayDType{nrangep->fileline(), VFlagChildDType{}, arrayp}; arrayp = new AstWildcardArrayDType{nrangep->fileline(), VFlagChildDType{}, arrayp};
} else { } else {
@ -166,7 +166,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name,
} }
if (GRAMMARP->m_varDecl == VVarType::WREAL) { if (GRAMMARP->m_varDecl == VVarType::WREAL) {
// dtypep might not be null, might be implicit LOGIC before we knew better // dtypep might not be null, might be implicit LOGIC before we knew better
dtypep = new AstBasicDType(fileline, VBasicDTypeKwd::DOUBLE); dtypep = new AstBasicDType{fileline, VBasicDTypeKwd::DOUBLE};
} }
if (!dtypep) { // Created implicitly if (!dtypep) { // Created implicitly
if (m_insideProperty) { if (m_insideProperty) {
@ -199,7 +199,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name,
// ARRAYDTYPE0(ARRAYDTYPE1(ARRAYDTYPE2(BASICTYPE3), RANGE), RANGE) // ARRAYDTYPE0(ARRAYDTYPE1(ARRAYDTYPE2(BASICTYPE3), RANGE), RANGE)
AstNodeDType* const arrayDTypep = createArray(dtypep, arrayp, false); AstNodeDType* const arrayDTypep = createArray(dtypep, arrayp, false);
AstVar* const nodep = new AstVar(fileline, type, name, VFlagChildDType(), arrayDTypep); AstVar* const nodep = new AstVar{fileline, type, name, VFlagChildDType(), arrayDTypep};
nodep->addAttrsp(attrsp); nodep->addAttrsp(attrsp);
nodep->ansi(m_pinAnsi); nodep->ansi(m_pinAnsi);
nodep->declTyped(m_varDeclTyped); nodep->declTyped(m_varDeclTyped);
@ -222,7 +222,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name,
} }
if (VN_IS(dtypep, ParseTypeDType)) { if (VN_IS(dtypep, ParseTypeDType)) {
// Parser needs to know what is a type // Parser needs to know what is a type
AstNode* const newp = new AstTypedefFwd(fileline, name); AstNode* const newp = new AstTypedefFwd{fileline, name};
AstNode::addNext<AstNode, AstNode>(nodep, newp); AstNode::addNext<AstNode, AstNode>(nodep, newp);
SYMP->reinsert(newp); SYMP->reinsert(newp);
} }

View File

@ -196,7 +196,7 @@ double V3ParseImp::lexParseTimenum(const char* textp) {
} }
*dp++ = '\0'; *dp++ = '\0';
const double d = strtod(strgp, nullptr); const double d = strtod(strgp, nullptr);
const string suffix(sp); const string suffix{sp};
double divisor = 1; double divisor = 1;
if (suffix == "s") { if (suffix == "s") {
@ -240,7 +240,7 @@ size_t V3ParseImp::ppInputToLex(char* buf, size_t max_size) {
got += len; got += len;
} }
if (debug() >= 9) { if (debug() >= 9) {
const string out = string(buf, got); const string out = std::string{buf, got};
cout << " inputToLex got=" << got << " '" << out << "'" << endl; cout << " inputToLex got=" << got << " '" << out << "'" << endl;
} }
// Note returns 0 at EOF // Note returns 0 at EOF
@ -274,7 +274,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
const string modname = V3Os::filenameNonExt(modfilename); const string modname = V3Os::filenameNonExt(modfilename);
UINFO(2, __FUNCTION__ << ": " << modname << (inLibrary ? " [LIB]" : "") << endl); UINFO(2, __FUNCTION__ << ": " << modname << (inLibrary ? " [LIB]" : "") << endl);
m_lexFileline = new FileLine(fileline); m_lexFileline = new FileLine{fileline};
m_lexFileline->newContent(); m_lexFileline->newContent();
m_bisonLastFileline = m_lexFileline; m_bisonLastFileline = m_lexFileline;
m_inLibrary = inLibrary; m_inLibrary = inLibrary;
@ -284,7 +284,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
if (!ok) { if (!ok) {
if (errmsg != "") return; // Threw error already if (errmsg != "") return; // Threw error already
// Create fake node for later error reporting // Create fake node for later error reporting
AstNodeModule* const nodep = new AstNotFoundModule(fileline, modname); AstNodeModule* const nodep = new AstNotFoundModule{fileline, modname};
v3Global.rootp()->addModulesp(nodep); v3Global.rootp()->addModulesp(nodep);
return; return;
} }
@ -589,7 +589,7 @@ std::ostream& operator<<(std::ostream& os, const V3ParseBisonYYSType& rhs) {
// V3Parse functions // V3Parse functions
V3Parse::V3Parse(AstNetlist* rootp, VInFilter* filterp, V3ParseSym* symp) { V3Parse::V3Parse(AstNetlist* rootp, VInFilter* filterp, V3ParseSym* symp) {
m_impp = new V3ParseImp(rootp, filterp, symp); m_impp = new V3ParseImp{rootp, filterp, symp};
} }
V3Parse::~V3Parse() { // V3Parse::~V3Parse() { //
VL_DO_CLEAR(delete m_impp, m_impp = nullptr); VL_DO_CLEAR(delete m_impp, m_impp = nullptr);

View File

@ -263,10 +263,10 @@ public:
void configure(FileLine* filelinep) { void configure(FileLine* filelinep) {
// configure() separate from constructor to avoid calling abstract functions // configure() separate from constructor to avoid calling abstract functions
m_preprocp = this; // Silly, but to make code more similar to Verilog-Perl m_preprocp = this; // Silly, but to make code more similar to Verilog-Perl
m_finFilelinep = new FileLine(filelinep->filename()); m_finFilelinep = new FileLine{filelinep->filename()};
m_finFilelinep->lineno(1); m_finFilelinep->lineno(1);
// Create lexer // Create lexer
m_lexp = new V3PreLex(this, filelinep); m_lexp = new V3PreLex{this, filelinep};
m_lexp->m_keepComments = keepComments(); m_lexp->m_keepComments = keepComments();
m_lexp->m_keepWhitespace = keepWhitespace(); m_lexp->m_keepWhitespace = keepWhitespace();
m_lexp->m_pedantic = pedantic(); m_lexp->m_pedantic = pedantic();
@ -793,7 +793,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam
} }
// Save file contents for future error reporting // Save file contents for future error reporting
FileLine* const flsp = new FileLine(filename); FileLine* const flsp = new FileLine{filename};
flsp->lineno(1); flsp->lineno(1);
flsp->newContent(); flsp->newContent();
for (const string& i : wholefile) flsp->contentp()->pushText(i); for (const string& i : wholefile) flsp->contentp()->pushText(i);

View File

@ -46,10 +46,10 @@ protected:
void boot() { void boot() {
// Create the implementation pointer // Create the implementation pointer
if (!s_preprocp) { if (!s_preprocp) {
FileLine* const cmdfl = new FileLine(FileLine::commandLineFilename()); FileLine* const cmdfl = new FileLine{FileLine::commandLineFilename()};
s_preprocp = V3PreProc::createPreProc(cmdfl); s_preprocp = V3PreProc::createPreProc(cmdfl);
// Default defines // Default defines
FileLine* const prefl = new FileLine(FileLine::builtInFilename()); FileLine* const prefl = new FileLine{FileLine::builtInFilename()};
s_preprocp->defineCmdLine(prefl, "VERILATOR", "1"); // LEAK_OK s_preprocp->defineCmdLine(prefl, "VERILATOR", "1"); // LEAK_OK
s_preprocp->defineCmdLine(prefl, "verilator", "1"); // LEAK_OK s_preprocp->defineCmdLine(prefl, "verilator", "1"); // LEAK_OK
s_preprocp->defineCmdLine(prefl, "verilator3", "1"); // LEAK_OK s_preprocp->defineCmdLine(prefl, "verilator3", "1"); // LEAK_OK
@ -161,7 +161,7 @@ void V3PreShell::preprocInclude(FileLine* fl, const string& modname) {
V3PreShellImp::s_preImp.preprocInclude(fl, modname); V3PreShellImp::s_preImp.preprocInclude(fl, modname);
} }
void V3PreShell::defineCmdLine(const string& name, const string& value) { void V3PreShell::defineCmdLine(const string& name, const string& value) {
FileLine* const prefl = new FileLine(FileLine::commandLineFilename()); FileLine* const prefl = new FileLine{FileLine::commandLineFilename()};
V3PreShellImp::s_preprocp->defineCmdLine(prefl, name, value); V3PreShellImp::s_preprocp->defineCmdLine(prefl, name, value);
} }
void V3PreShell::undef(const string& name) { V3PreShellImp::s_preprocp->undef(name); } void V3PreShell::undef(const string& name) { V3PreShellImp::s_preprocp->undef(name); }

View File

@ -58,9 +58,9 @@ void V3ScoreboardBase::selfTest() {
UASSERT(!sb.needsRescore(), "SelfTest: Empty sb should not need rescore."); UASSERT(!sb.needsRescore(), "SelfTest: Empty sb should not need rescore.");
ScoreboardTestElem e1(10); ScoreboardTestElem e1{10};
ScoreboardTestElem e2(20); ScoreboardTestElem e2{20};
ScoreboardTestElem e3(30); ScoreboardTestElem e3{30};
sb.add(&e1); sb.add(&e1);
sb.add(&e2); sb.add(&e2);

View File

@ -263,7 +263,7 @@ void VHashSha256::insert(const void* datap, size_t length) {
// If there are large inserts it would be more efficient to avoid this copy // If there are large inserts it would be more efficient to avoid this copy
// by copying bytes in the loop below from either m_remainder or the data // by copying bytes in the loop below from either m_remainder or the data
// as appropriate. // as appropriate.
tempData = m_remainder + string(static_cast<const char*>(datap), length); tempData = m_remainder + std::string{static_cast<const char*>(datap), length};
chunkLen = tempData.length(); chunkLen = tempData.length();
chunkp = reinterpret_cast<const uint8_t*>(tempData.data()); chunkp = reinterpret_cast<const uint8_t*>(tempData.data());
} }
@ -286,7 +286,7 @@ void VHashSha256::insert(const void* datap, size_t length) {
sha256Block(m_inthash, w); sha256Block(m_inthash, w);
} }
m_remainder = string(reinterpret_cast<const char*>(chunkp + posBegin), chunkLen - posEnd); m_remainder = std::string(reinterpret_cast<const char*>(chunkp + posBegin), chunkLen - posEnd);
} }
void VHashSha256::finalize() { void VHashSha256::finalize() {
@ -426,7 +426,7 @@ string VName::dehash(const string& in) {
const auto begin_vhsh const auto begin_vhsh
= std::search(search_begin, search_end, std::begin(VHSH), std::end(VHSH) - 1); = std::search(search_begin, search_end, std::begin(VHSH), std::end(VHSH) - 1);
if (begin_vhsh != search_end) { if (begin_vhsh != search_end) {
const std::string vhsh(begin_vhsh, search_end); const std::string vhsh{begin_vhsh, search_end};
const auto& it = s_dehashMap.find(vhsh); const auto& it = s_dehashMap.find(vhsh);
UASSERT(it != s_dehashMap.end(), "String not in reverse hash map '" << vhsh << "'"); UASSERT(it != s_dehashMap.end(), "String not in reverse hash map '" << vhsh << "'");
// Is this not the first component, but the first to require dehashing? // Is this not the first component, but the first to require dehashing?
@ -435,13 +435,13 @@ string VName::dehash(const string& in) {
dehashed = in.substr(0, last_dot_pos); dehashed = in.substr(0, last_dot_pos);
} }
// Append the unhashed part of the component. // Append the unhashed part of the component.
dehashed += std::string(search_begin, begin_vhsh); dehashed += std::string{search_begin, begin_vhsh};
// Append the bit that was lost to truncation but retrieved from the dehash map. // Append the bit that was lost to truncation but retrieved from the dehash map.
dehashed += it->second; dehashed += it->second;
} }
// This component doesn't need dehashing but a previous one might have. // This component doesn't need dehashing but a previous one might have.
else if (!dehashed.empty()) { else if (!dehashed.empty()) {
dehashed += std::string(search_begin, search_end); dehashed += std::string{search_begin, search_end};
} }
if (next_dot_pos != string::npos) { if (next_dot_pos != string::npos) {

View File

@ -238,7 +238,7 @@ private:
// METHODS // METHODS
SubstVarEntry* getEntryp(AstVarRef* nodep) { SubstVarEntry* getEntryp(AstVarRef* nodep) {
if (!nodep->varp()->user1p()) { if (!nodep->varp()->user1p()) {
SubstVarEntry* const entryp = new SubstVarEntry(nodep->varp()); SubstVarEntry* const entryp = new SubstVarEntry{nodep->varp()};
m_entryps.push_back(entryp); m_entryps.push_back(entryp);
nodep->varp()->user1p(entryp); nodep->varp()->user1p(entryp);
return entryp; return entryp;
@ -290,7 +290,7 @@ private:
if (debug() > 5) nodep->dumpTree(cout, " substw_old: "); if (debug() > 5) nodep->dumpTree(cout, " substw_old: ");
AstNode* newp = substp->cloneTree(true); AstNode* newp = substp->cloneTree(true);
if (!nodep->isQuad() && newp->isQuad()) { if (!nodep->isQuad() && newp->isQuad()) {
newp = new AstCCast(newp->fileline(), newp, nodep); newp = new AstCCast{newp->fileline(), newp, nodep};
} }
if (debug() > 5) newp->dumpTree(cout, " w_new: "); if (debug() > 5) newp->dumpTree(cout, " w_new: ");
nodep->replaceWith(newp); nodep->replaceWith(newp);

View File

@ -90,7 +90,7 @@ public:
void addVertex(const T_Key& key) { void addVertex(const T_Key& key) {
const auto itr = m_vertices.find(key); const auto itr = m_vertices.find(key);
UASSERT(itr == m_vertices.end(), "Vertex already exists with same key"); UASSERT(itr == m_vertices.end(), "Vertex already exists with same key");
Vertex* v = new Vertex(this, key); Vertex* v = new Vertex{this, key};
m_vertices[key] = v; m_vertices[key] = v;
} }
@ -118,8 +118,8 @@ public:
// which uniquely identifies a single bidir edge. Luckily we // which uniquely identifies a single bidir edge. Luckily we
// can do both efficiently. // can do both efficiently.
const uint64_t userValue = (static_cast<uint64_t>(cost) << 32) | edgeId; const uint64_t userValue = (static_cast<uint64_t>(cost) << 32) | edgeId;
(new V3GraphEdge(this, fp, tp, cost))->user(userValue); (new V3GraphEdge{this, fp, tp, cost})->user(userValue);
(new V3GraphEdge(this, tp, fp, cost))->user(userValue); (new V3GraphEdge{this, tp, fp, cost})->user(userValue);
} }
static uint32_t getEdgeId(const V3GraphEdge* edgep) { static uint32_t getEdgeId(const V3GraphEdge* edgep) {
@ -581,11 +581,11 @@ void V3TSP::selfTestStates() {
// Linear test -- coords all along the x-axis // Linear test -- coords all along the x-axis
{ {
V3TSP::StateVec states; V3TSP::StateVec states;
const TspTestState s10(10, 0); const TspTestState s10{10, 0};
const TspTestState s60(60, 0); const TspTestState s60{60, 0};
const TspTestState s20(20, 0); const TspTestState s20{20, 0};
const TspTestState s100(100, 0); const TspTestState s100{100, 0};
const TspTestState s5(5, 0); const TspTestState s5{5, 0};
states.push_back(&s10); states.push_back(&s10);
states.push_back(&s60); states.push_back(&s60);
states.push_back(&s20); states.push_back(&s20);
@ -615,13 +615,13 @@ void V3TSP::selfTestStates() {
// Test that tspSort() will rotate the list for minimum cost. // Test that tspSort() will rotate the list for minimum cost.
{ {
V3TSP::StateVec states; V3TSP::StateVec states;
const TspTestState a(0, 0); const TspTestState a{0, 0};
const TspTestState b(100, 0); const TspTestState b{100, 0};
const TspTestState c(200, 0); const TspTestState c{200, 0};
const TspTestState d(200, 100); const TspTestState d{200, 100};
const TspTestState e(150, 150); const TspTestState e{150, 150};
const TspTestState f(0, 150); const TspTestState f{0, 150};
const TspTestState g(0, 100); const TspTestState g{0, 100};
states.push_back(&a); states.push_back(&a);
states.push_back(&b); states.push_back(&b);

View File

@ -267,7 +267,7 @@ private:
UndrivenVarEntry* getEntryp(AstVar* nodep, int which_user) { UndrivenVarEntry* getEntryp(AstVar* nodep, int which_user) {
if (!(which_user == 1 ? nodep->user1p() : nodep->user2p())) { if (!(which_user == 1 ? nodep->user1p() : nodep->user2p())) {
UndrivenVarEntry* const entryp = new UndrivenVarEntry(nodep); UndrivenVarEntry* const entryp = new UndrivenVarEntry{nodep};
// UINFO(9," Associate u="<<which_user<<" "<<cvtToHex(this)<<" "<<nodep->name()<<endl); // UINFO(9," Associate u="<<which_user<<" "<<cvtToHex(this)<<" "<<nodep->name()<<endl);
m_entryps[which_user].push_back(entryp); m_entryps[which_user].push_back(entryp);
if (which_user == 1) { if (which_user == 1) {