Internals: Remove extra single-line {}. No functional change.

This commit is contained in:
Wilson Snyder 2024-03-27 17:57:49 -04:00
parent 341963e820
commit 0ff77fc352
35 changed files with 53 additions and 53 deletions

View File

@ -605,7 +605,7 @@ WDataOutP VL_POWSS_WWW(int obits, int, int rbits, WDataOutP owp, const WDataInP
const int words = VL_WORDS_I(obits); const int words = VL_WORDS_I(obits);
VL_ZERO_W(obits, owp); VL_ZERO_W(obits, owp);
EData lor = 0; // 0=all zeros, ~0=all ones, else mix EData lor = 0; // 0=all zeros, ~0=all ones, else mix
for (int i = 1; i < (words - 1); ++i) { lor |= lwp[i]; } for (int i = 1; i < (words - 1); ++i) lor |= lwp[i];
lor |= ((lwp[words - 1] == VL_MASK_E(rbits)) ? ~VL_EUL(0) : 0); lor |= ((lwp[words - 1] == VL_MASK_E(rbits)) ? ~VL_EUL(0) : 0);
if (lor == 0 && lwp[0] == 0) { // "X" so return 0 if (lor == 0 && lwp[0] == 0) { // "X" so return 0
return owp; return owp;
@ -1439,8 +1439,8 @@ void _vl_string_to_vint(int obits, void* destp, size_t srclen, const char* srcp)
char* op = reinterpret_cast<char*>(destp); char* op = reinterpret_cast<char*>(destp);
if (srclen > bytes) srclen = bytes; // Don't overflow destination if (srclen > bytes) srclen = bytes; // Don't overflow destination
size_t i = 0; size_t i = 0;
for (i = 0; i < srclen; ++i) { *op++ = srcp[srclen - 1 - i]; } for (i = 0; i < srclen; ++i) *op++ = srcp[srclen - 1 - i];
for (; i < bytes; ++i) { *op++ = 0; } for (; i < bytes; ++i) *op++ = 0;
} }
static IData getLine(std::string& str, IData fpi, size_t maxLen) VL_MT_SAFE { static IData getLine(std::string& str, IData fpi, size_t maxLen) VL_MT_SAFE {

View File

@ -116,7 +116,7 @@ IData VL_DIST_ERLANG(IData& seedr, IData uk, IData umean) VL_MT_SAFE {
return 0; return 0;
} }
double x = 1.0; double x = 1.0;
for (int32_t i = 1; i <= k; i++) { x = x * _vl_dbase_uniform(seedr, 0, 1); } for (int32_t i = 1; i <= k; i++) x = x * _vl_dbase_uniform(seedr, 0, 1);
const double a = static_cast<double>(mean); const double a = static_cast<double>(mean);
const double b = static_cast<double>(k); const double b = static_cast<double>(k);
double r = -a * log(x) / b; double r = -a * log(x) / b;

View File

@ -582,7 +582,7 @@ public:
m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_WDATA; m_offloadBufferWritep[0] = (bits << 4) | VerilatedTraceOffloadCommand::CHG_WDATA;
m_offloadBufferWritep[1] = code; m_offloadBufferWritep[1] = code;
m_offloadBufferWritep += 2; m_offloadBufferWritep += 2;
for (int i = 0; i < (bits + 31) / 32; ++i) { *m_offloadBufferWritep++ = newvalp[i]; } for (int i = 0; i < (bits + 31) / 32; ++i) *m_offloadBufferWritep++ = newvalp[i];
VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp);); VL_DEBUG_IF(assert(m_offloadBufferWritep <= m_offloadBufferEndp););
} }
void chgDouble(uint32_t code, double newval) { void chgDouble(uint32_t code, double newval) {

View File

@ -555,7 +555,7 @@ public:
m_fullname_string = std::string{m_fullname} + "::"; m_fullname_string = std::string{m_fullname} + "::";
if (m_fullname_string == "\\$unit ::") m_fullname_string = "$unit::"; if (m_fullname_string == "\\$unit ::") m_fullname_string = "$unit::";
if (strcmp(m_name, "\\$unit ") == 0) { m_name = d_unit; } if (strcmp(m_name, "\\$unit ") == 0) m_name = d_unit;
} }
static VerilatedVpioPackage* castp(vpiHandle h) { static VerilatedVpioPackage* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioPackage*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioPackage*>(reinterpret_cast<VerilatedVpio*>(h));

View File

@ -2088,7 +2088,7 @@ void AstSliceSel::dump(std::ostream& str) const {
if (declRange().ranged()) str << " decl" << declRange(); if (declRange().ranged()) str << " decl" << declRange();
} }
void AstSliceSel::dumpJson(std::ostream& str) const { void AstSliceSel::dumpJson(std::ostream& str) const {
if (declRange().ranged()) { dumpJsonStr(str, "declRange", cvtToStr(declRange())); } if (declRange().ranged()) dumpJsonStr(str, "declRange", cvtToStr(declRange()));
dumpJsonGen(str); dumpJsonGen(str);
} }
void AstMTaskBody::dump(std::ostream& str) const { void AstMTaskBody::dump(std::ostream& str) const {

View File

@ -198,12 +198,12 @@ class ClassVisitor final : public VNVisitor {
void visit(AstInitial* nodep) override { void visit(AstInitial* nodep) override {
// But not AstInitialAutomatic, which remains under the class // But not AstInitialAutomatic, which remains under the class
iterateChildren(nodep); iterateChildren(nodep);
if (m_packageScopep) { m_toScopeMoves.emplace_back(nodep, m_packageScopep); } if (m_packageScopep) m_toScopeMoves.emplace_back(nodep, m_packageScopep);
} }
void visit(AstInitialStatic* nodep) override { void visit(AstInitialStatic* nodep) override {
// But not AstInitialAutomatic, which remains under the class // But not AstInitialAutomatic, which remains under the class
iterateChildren(nodep); iterateChildren(nodep);
if (m_packageScopep) { m_toScopeMoves.emplace_back(nodep, m_packageScopep); } if (m_packageScopep) m_toScopeMoves.emplace_back(nodep, m_packageScopep);
} }
void setStructModulep(AstNodeUOrStructDType* const dtypep) { void setStructModulep(AstNodeUOrStructDType* const dtypep) {

View File

@ -286,7 +286,7 @@ public:
} }
void update(const V3ConfigFile& file) { void update(const V3ConfigFile& file) {
// Copy in all Attributes // Copy in all Attributes
for (const auto& itr : file.m_lineAttrs) { m_lineAttrs[itr.first] |= itr.second; } for (const auto& itr : file.m_lineAttrs) m_lineAttrs[itr.first] |= itr.second;
// Copy in all ignores // Copy in all ignores
for (const auto& ignLine : file.m_ignLines) m_ignLines.insert(ignLine); for (const auto& ignLine : file.m_ignLines) m_ignLines.insert(ignLine);
// Update the iterator after the list has changed // Update the iterator after the list has changed

View File

@ -26,7 +26,7 @@
EmitCParentModule::EmitCParentModule() { EmitCParentModule::EmitCParentModule() {
const auto setAll = [](AstNodeModule* modp) -> void { const auto setAll = [](AstNodeModule* modp) -> void {
for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) { for (AstNode* nodep = modp->stmtsp(); nodep; nodep = nodep->nextp()) {
if (VN_IS(nodep, CFunc) || VN_IS(nodep, Var)) { nodep->user4p(modp); } if (VN_IS(nodep, CFunc) || VN_IS(nodep, Var)) nodep->user4p(modp);
} }
}; };
for (AstNode* modp = v3Global.rootp()->modulesp(); modp; modp = modp->nextp()) { for (AstNode* modp = v3Global.rootp()->modulesp(); modp; modp = modp->nextp()) {
@ -173,7 +173,7 @@ void EmitCBaseVisitorConst::emitVarDecl(const AstVar* nodep, bool asRef) {
putns(nodep, "&"); putns(nodep, "&");
} }
putns(nodep, nodep->nameProtect()); putns(nodep, nodep->nameProtect());
if (asRef && refNeedParens) { puts(")"); } if (asRef && refNeedParens) puts(")");
emitDeclArrayBrackets(nodep); emitDeclArrayBrackets(nodep);
puts(";\n"); puts(";\n");
} else if (nodep->isIO() && basicp && !basicp->isOpaque()) { } else if (nodep->isIO() && basicp && !basicp->isOpaque()) {
@ -203,7 +203,7 @@ void EmitCBaseVisitorConst::emitVarDecl(const AstVar* nodep, bool asRef) {
puts("&"); puts("&");
} }
puts(nodep->nameProtect()); puts(nodep->nameProtect());
if (asRef && refNeedParens) { puts(")"); } if (asRef && refNeedParens) puts(")");
emitDeclArrayBrackets(nodep); emitDeclArrayBrackets(nodep);
// If it's a packed struct/array then nodep->width is the whole // If it's a packed struct/array then nodep->width is the whole
// thing, msb/lsb is just lowest dimension // thing, msb/lsb is just lowest dimension

View File

@ -858,7 +858,7 @@ class EmitCTrace final : EmitCFunc {
void emitTraceValue(AstTraceInc* nodep, int arrayindex) { void emitTraceValue(AstTraceInc* nodep, int arrayindex) {
if (AstVarRef* const varrefp = VN_CAST(nodep->valuep(), VarRef)) { if (AstVarRef* const varrefp = VN_CAST(nodep->valuep(), VarRef)) {
AstVar* const varp = varrefp->varp(); AstVar* const varp = varrefp->varp();
if (varp->isEvent()) { puts("&"); } if (varp->isEvent()) puts("&");
puts("("); puts("(");
if (emitTraceIsScBigUint(nodep)) { if (emitTraceIsScBigUint(nodep)) {
puts("(uint32_t*)"); puts("(uint32_t*)");

View File

@ -199,7 +199,7 @@ class CMakeEmitter final {
*of << "target_link_libraries(${TOP_TARGET_NAME} PRIVATE " << prefix << ")\n"; *of << "target_link_libraries(${TOP_TARGET_NAME} PRIVATE " << prefix << ")\n";
if (!children.empty()) { if (!children.empty()) {
*of << "target_link_libraries(" << prefix << " INTERFACE"; *of << "target_link_libraries(" << prefix << " INTERFACE";
for (const auto& childr : children) { *of << " " << (childr)->hierPrefix(); } for (const auto& childr : children) *of << " " << (childr)->hierPrefix();
*of << ")\n"; *of << ")\n";
} }
*of << "verilate(" << prefix << " PREFIX " << prefix << " TOP_MODULE " *of << "verilate(" << prefix << " PREFIX " << prefix << " TOP_MODULE "

View File

@ -684,14 +684,14 @@ class EmitCModel final : public EmitCFunc {
iterateConst(funcp); iterateConst(funcp);
} }
if (m_ofp) { VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr); } if (m_ofp) VL_DO_CLEAR(delete m_ofp, m_ofp = nullptr);
} }
void main(AstNodeModule* modp) { void main(AstNodeModule* modp) {
m_modp = modp; m_modp = modp;
emitHeader(modp); emitHeader(modp);
emitImplementation(modp); emitImplementation(modp);
if (v3Global.dpi()) { emitDpiExportDispatchers(modp); } if (v3Global.dpi()) emitDpiExportDispatchers(modp);
} }
// VISITORS // VISITORS

View File

@ -263,7 +263,7 @@ class EmitXmlFileVisitor final : public VNVisitorConst {
puts(" left=\"" + cvtToStr(nodep->left()) + "\""); puts(" left=\"" + cvtToStr(nodep->left()) + "\"");
puts(" right=\"" + cvtToStr(nodep->right()) + "\""); puts(" right=\"" + cvtToStr(nodep->right()) + "\"");
} }
if (nodep->isSigned()) { puts(" signed=\"true\""); } if (nodep->isSigned()) puts(" signed=\"true\"");
puts("/>\n"); puts("/>\n");
} }
void visit(AstIfaceRefDType* nodep) override { void visit(AstIfaceRefDType* nodep) override {

View File

@ -193,7 +193,7 @@ void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra)
<< endl; << endl;
} }
} }
if (!msg_additional.empty()) { std::cerr << msg_additional; } if (!msg_additional.empty()) std::cerr << msg_additional;
// If first warning is not the user's fault (internal/unsupported) then give the website // If first warning is not the user's fault (internal/unsupported) then give the website
// Not later warnings, as a internal may be caused by an earlier problem // Not later warnings, as a internal may be caused by an earlier problem
if (tellManual() == 0) { if (tellManual() == 0) {

View File

@ -272,7 +272,7 @@ public:
bool isRenamed() const { return renamedTo() != V3ErrorCode{EC_MIN}; } bool isRenamed() const { return renamedTo() != V3ErrorCode{EC_MIN}; }
bool isUnder(V3ErrorCode other) { bool isUnder(V3ErrorCode other) {
// backwards compatibility inheritance-like warnings // backwards compatibility inheritance-like warnings
if (m_e == other) { return true; } if (m_e == other) return true;
if (other == V3ErrorCode::WIDTH) { if (other == V3ErrorCode::WIDTH) {
return (m_e == WIDTHEXPAND || m_e == WIDTHTRUNC || m_e == WIDTHXZEXPAND); return (m_e == WIDTHEXPAND || m_e == WIDTHTRUNC || m_e == WIDTHXZEXPAND);
} }

View File

@ -588,7 +588,7 @@ class ExpandVisitor final : public VNVisitor {
VL_DO_DANGLING(destp->deleteTree(), destp); VL_DO_DANGLING(destp->deleteTree(), destp);
} else { } else {
UINFO(8, " ASSIGNSEL(const,narrow) " << nodep << endl); UINFO(8, " ASSIGNSEL(const,narrow) " << nodep << endl);
if (destp->isQuad() && !rhsp->isQuad()) { rhsp = new AstCCast{nfl, rhsp, nodep}; } if (destp->isQuad() && !rhsp->isQuad()) rhsp = new AstCCast{nfl, rhsp, nodep};
AstNodeExpr* oldvalp = destp->cloneTreePure(true); AstNodeExpr* oldvalp = destp->cloneTreePure(true);
fixCloneLvalue(oldvalp); fixCloneLvalue(oldvalp);
if (!ones) oldvalp = new AstAnd{lfl, new AstConst{lfl, maskold}, oldvalp}; if (!ones) oldvalp = new AstAnd{lfl, new AstConst{lfl, maskold}, oldvalp};
@ -656,7 +656,7 @@ class ExpandVisitor final : public VNVisitor {
V3Number maskwidth{nodep, destp->widthMin()}; V3Number maskwidth{nodep, destp->widthMin()};
for (int bit = 0; bit < lhsp->widthConst(); bit++) maskwidth.setBit(bit, 1); for (int bit = 0; bit < lhsp->widthConst(); bit++) maskwidth.setBit(bit, 1);
if (destp->isQuad() && !rhsp->isQuad()) { rhsp = new AstCCast{nfl, rhsp, nodep}; } if (destp->isQuad() && !rhsp->isQuad()) rhsp = new AstCCast{nfl, rhsp, nodep};
if (!ones) { if (!ones) {
oldvalp = new AstAnd{ oldvalp = new AstAnd{
lfl, lfl,
@ -741,7 +741,7 @@ class ExpandVisitor final : public VNVisitor {
UASSERT_OBJ(constp, nodep, UASSERT_OBJ(constp, nodep,
"Replication value isn't a constant. Checked earlier!"); "Replication value isn't a constant. Checked earlier!");
const uint32_t times = constp->toUInt(); const uint32_t times = constp->toUInt();
if (nodep->isQuad() && !lhsp->isQuad()) { lhsp = new AstCCast{fl, lhsp, nodep}; } if (nodep->isQuad() && !lhsp->isQuad()) lhsp = new AstCCast{fl, lhsp, nodep};
newp = lhsp->cloneTreePure(true); newp = lhsp->cloneTreePure(true);
for (unsigned repnum = 1; repnum < times; repnum++) { for (unsigned repnum = 1; repnum < times; repnum++) {
const int rhsshift = repnum * lhswidth; const int rhsshift = repnum * lhswidth;

View File

@ -406,7 +406,7 @@ bool FileLine::warnIsOff(V3ErrorCode code) const {
if ((code.lintError() || code.styleError()) && !msgEn().test(V3ErrorCode::I_LINT)) { if ((code.lintError() || code.styleError()) && !msgEn().test(V3ErrorCode::I_LINT)) {
return true; return true;
} }
if ((code.unusedError()) && !msgEn().test(V3ErrorCode::I_UNUSED)) { return true; } if ((code.unusedError()) && !msgEn().test(V3ErrorCode::I_UNUSED)) return true;
return false; return false;
} }

View File

@ -277,7 +277,7 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
varp->trace(false); varp->trace(false);
} }
if (v3Global.opt.noTraceTop() && varp->isIO()) { varp->trace(false); } if (v3Global.opt.noTraceTop() && varp->isIO()) varp->trace(false);
AstPin* const pinp = new AstPin{ AstPin* const pinp = new AstPin{
oldvarp->fileline(), 0, varp->name(), oldvarp->fileline(), 0, varp->name(),

View File

@ -101,7 +101,7 @@ public:
} }
/// Release/unlock mutex /// Release/unlock mutex
void unlock() VL_RELEASE() VL_MT_SAFE { void unlock() VL_RELEASE() VL_MT_SAFE {
if (V3MutexConfig::s().enable()) { m_mutex.unlock(); } if (V3MutexConfig::s().enable()) m_mutex.unlock();
} }
/// Try to acquire mutex. Returns true on success, and false on failure. /// Try to acquire mutex. Returns true on success, and false on failure.
bool try_lock() VL_TRY_ACQUIRE(true) VL_MT_SAFE { bool try_lock() VL_TRY_ACQUIRE(true) VL_MT_SAFE {

View File

@ -105,7 +105,7 @@ V3Number::V3Number(VerilogStringLiteral, AstNode* nodep, const string& str) {
const int topos = str.length() - 1 - pos; const int topos = str.length() - 1 - pos;
ValueAndX& v = m_data.num()[topos / 4]; ValueAndX& v = m_data.num()[topos / 4];
for (int bit = 0; bit < 8; ++bit) { for (int bit = 0; bit < 8; ++bit) {
if (str[pos] & (1UL << bit)) { v.m_value |= (1UL << (bit + (topos % 4) * 8)); } if (str[pos] & (1UL << bit)) v.m_value |= (1UL << (bit + (topos % 4) * 8));
} }
} }
} }
@ -991,7 +991,7 @@ V3Hash V3Number::toHash() const {
if (isString()) { if (isString()) {
hash += V3Hash{m_data.str()}; hash += V3Hash{m_data.str()};
} else { } else {
for (int i = 0; i < words(); ++i) { hash += m_data.num()[i].m_value; } for (int i = 0; i < words(); ++i) hash += m_data.num()[i].m_value;
} }
return hash; return hash;
} }
@ -2053,7 +2053,7 @@ V3Number& V3Number::opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool
uint32_t vn[VL_MULS_MAX_WORDS + 1]; // v normalized uint32_t vn[VL_MULS_MAX_WORDS + 1]; // v normalized
// Zero for ease of debugging and to save having to zero for shifts // Zero for ease of debugging and to save having to zero for shifts
for (int i = 0; i < words; i++) { m_data.num()[i].m_value = 0; } for (int i = 0; i < words; i++) m_data.num()[i].m_value = 0;
for (int i = 0; i < words + 1; i++) { un[i] = vn[i] = 0; } // +1 as vn may get extra word for (int i = 0; i < words + 1; i++) { un[i] = vn[i] = 0; } // +1 as vn may get extra word
// Algorithm requires divisor MSB to be set // Algorithm requires divisor MSB to be set
@ -2270,7 +2270,7 @@ V3Number& V3Number::opExtendXZ(const V3Number& lhs, uint32_t lbits) {
NUM_ASSERT_OP_ARGS1(lhs); NUM_ASSERT_OP_ARGS1(lhs);
NUM_ASSERT_LOGIC_ARGS1(lhs); NUM_ASSERT_LOGIC_ARGS1(lhs);
setZero(); setZero();
for (int bit = 0; bit < width(); bit++) { setBit(bit, lhs.bitIsExtend(bit, lbits)); } for (int bit = 0; bit < width(); bit++) setBit(bit, lhs.bitIsExtend(bit, lbits));
return *this; return *this;
} }
@ -2499,7 +2499,7 @@ V3Number& V3Number::opReplN(const V3Number& lhs, uint32_t rhsval) {
NUM_ASSERT_STRING_ARGS1(lhs); NUM_ASSERT_STRING_ARGS1(lhs);
string out; string out;
out.reserve(lhs.toString().length() * rhsval); out.reserve(lhs.toString().length() * rhsval);
for (unsigned times = 0; times < rhsval; times++) { out += lhs.toString(); } for (unsigned times = 0; times < rhsval; times++) out += lhs.toString();
return setString(out); return setString(out);
} }
V3Number& V3Number::opToLowerN(const V3Number& lhs) { V3Number& V3Number::opToLowerN(const V3Number& lhs) {

View File

@ -456,7 +456,7 @@ public:
private: private:
uint32_t bitsValue(int lsb, int nbits) const VL_MT_SAFE { uint32_t bitsValue(int lsb, int nbits) const VL_MT_SAFE {
uint32_t v = 0; uint32_t v = 0;
for (int bitn = 0; bitn < nbits; bitn++) { v |= (bitIs1(lsb + bitn) << bitn); } for (int bitn = 0; bitn < nbits; bitn++) v |= (bitIs1(lsb + bitn) << bitn);
return v; return v;
} }

View File

@ -162,7 +162,7 @@ V3OptionParser::ActionIfs* V3OptionParser::find(const char* optp) {
if (act.second->isOnOffAllowed()) { // Find starts with "-no" if (act.second->isOnOffAllowed()) { // Find starts with "-no"
if (const char* const nop if (const char* const nop
= VString::startsWith(optp, "-no") ? (optp + std::strlen("-no")) : nullptr) { = VString::startsWith(optp, "-no") ? (optp + std::strlen("-no")) : nullptr) {
if (act.first == nop || act.first == ("-"s + nop)) { return act.second.get(); } if (act.first == nop || act.first == ("-"s + nop)) return act.second.get();
} }
} else if (act.second->isPartialMatchAllowed()) { } else if (act.second->isPartialMatchAllowed()) {
if (VString::startsWith(optp, act.first)) return act.second.get(); if (VString::startsWith(optp, act.first)) return act.second.get();

View File

@ -342,7 +342,7 @@ class ParamProcessor final {
key += " "; key += " ";
key += paramValueString(dtypep->subDTypep()); key += paramValueString(dtypep->subDTypep());
} else if (const AstBasicDType* const dtypep = VN_CAST(nodep, BasicDType)) { } else if (const AstBasicDType* const dtypep = VN_CAST(nodep, BasicDType)) {
if (dtypep->isSigned()) { key += " signed"; } if (dtypep->isSigned()) key += " signed";
if (dtypep->isRanged()) { if (dtypep->isRanged()) {
key += "[" + cvtToStr(dtypep->left()) + ":" + cvtToStr(dtypep->right()) + "]"; key += "[" + cvtToStr(dtypep->left()) + ":" + cvtToStr(dtypep->right()) + "]";
} }

View File

@ -248,7 +248,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, const string& name,
} else { } else {
nodep->trace(allTracingOn(nodep->fileline())); nodep->trace(allTracingOn(nodep->fileline()));
} }
if (nodep->varType().isVPIAccessible()) { nodep->addAttrsp(GRAMMARP->cloneScopedSigAttr()); } if (nodep->varType().isVPIAccessible()) nodep->addAttrsp(GRAMMARP->cloneScopedSigAttr());
// Remember the last variable created, so we can attach attributes to it in later parsing // Remember the last variable created, so we can attach attributes to it in later parsing
GRAMMARP->m_varAttrp = nodep; GRAMMARP->m_varAttrp = nodep;

View File

@ -866,7 +866,7 @@ class PackedVarRef final {
static void dedupRefs(std::vector<PackedVarRefEntry>& refs) { static void dedupRefs(std::vector<PackedVarRefEntry>& refs) {
// Use raw pointer to dedup // Use raw pointer to dedup
std::map<AstNode*, size_t, AstNodeComparator> nodes; std::map<AstNode*, size_t, AstNodeComparator> nodes;
for (size_t i = 0; i < refs.size(); ++i) { nodes.emplace(refs[i].nodep(), i); } for (size_t i = 0; i < refs.size(); ++i) nodes.emplace(refs[i].nodep(), i);
std::vector<PackedVarRefEntry> vect; std::vector<PackedVarRefEntry> vect;
vect.reserve(nodes.size()); vect.reserve(nodes.size());
for (const auto& pair : nodes) vect.push_back(refs[pair.second]); for (const auto& pair : nodes) vect.push_back(refs[pair.second]);

View File

@ -544,7 +544,7 @@ string VName::dehash(const string& in) {
if (next_dot_pos != string::npos) { if (next_dot_pos != string::npos) {
// Is there a __DOT__ to add to the dehashed version of 'in'? // Is there a __DOT__ to add to the dehashed version of 'in'?
if (!dehashed.empty()) { dehashed += "__DOT__"; } if (!dehashed.empty()) dehashed += "__DOT__";
last_dot_pos = next_dot_pos + DOT_LEN; last_dot_pos = next_dot_pos + DOT_LEN;
} else { } else {
last_dot_pos = string::npos; last_dot_pos = string::npos;

View File

@ -125,7 +125,7 @@ public:
const std::list<Vertex*> keysToVertexList(const std::vector<T_Key>& odds) { const std::list<Vertex*> keysToVertexList(const std::vector<T_Key>& odds) {
std::list<Vertex*> vertices; std::list<Vertex*> vertices;
for (unsigned i = 0; i < odds.size(); ++i) { vertices.push_back(findVertex(odds.at(i))); } for (unsigned i = 0; i < odds.size(); ++i) vertices.push_back(findVertex(odds.at(i)));
return vertices; return vertices;
} }

View File

@ -110,7 +110,7 @@ public:
} }
AstVarScope* varScopep() { AstVarScope* varScopep() {
if (!m_varScopep) { m_varScopep = v3Global.rootp()->constPoolp()->findTable(m_initp); } if (!m_varScopep) m_varScopep = v3Global.rootp()->constPoolp()->findTable(m_initp);
return m_varScopep; return m_varScopep;
} }
}; };
@ -261,7 +261,7 @@ private:
VL_MASK_I(m_inWidthBits)); VL_MASK_I(m_inWidthBits));
// Set sizes of output tables // Set sizes of output tables
for (TableOutputVar& tov : m_outVarps) { tov.setTableSize(VL_MASK_I(m_inWidthBits)); } for (TableOutputVar& tov : m_outVarps) tov.setTableSize(VL_MASK_I(m_inWidthBits));
// Populate the tables // Populate the tables
createTables(nodep, outputAssignedTableBuilder); createTables(nodep, outputAssignedTableBuilder);

View File

@ -27,7 +27,7 @@ void V3ThreadPool::resize(unsigned n) VL_MT_UNSAFE VL_EXCLUDES(m_mutex)
VL_EXCLUDES(m_stoppedJobsMutex) VL_EXCLUDES(V3MtDisabledLock::instance()) { VL_EXCLUDES(m_stoppedJobsMutex) VL_EXCLUDES(V3MtDisabledLock::instance()) {
// At least one thread (main) // At least one thread (main)
n = std::max(1u, n); n = std::max(1u, n);
if (n == (m_workers.size() + 1)) { return; } if (n == (m_workers.size() + 1)) return;
// This function is not thread-safe and can result in race between threads // This function is not thread-safe and can result in race between threads
UASSERT(V3MutexConfig::s().lockConfig(), UASSERT(V3MutexConfig::s().lockConfig(),
"Mutex config needs to be locked before starting ThreadPool"); "Mutex config needs to be locked before starting ThreadPool");
@ -60,7 +60,7 @@ void V3ThreadPool::resize(unsigned n) VL_MT_UNSAFE VL_EXCLUDES(m_mutex)
void V3ThreadPool::suspendMultithreading() VL_MT_SAFE VL_EXCLUDES(m_mutex) void V3ThreadPool::suspendMultithreading() VL_MT_SAFE VL_EXCLUDES(m_mutex)
VL_EXCLUDES(m_stoppedJobsMutex) { VL_EXCLUDES(m_stoppedJobsMutex) {
V3LockGuard stoppedJobsLock{m_stoppedJobsMutex}; V3LockGuard stoppedJobsLock{m_stoppedJobsMutex};
if (!m_workers.empty()) { stopOtherThreads(); } if (!m_workers.empty()) stopOtherThreads();
if (!m_mutex.try_lock()) { if (!m_mutex.try_lock()) {
v3fatal("Tried to suspend thread pool when other thread uses it."); v3fatal("Tried to suspend thread pool when other thread uses it.");
@ -75,7 +75,7 @@ void V3ThreadPool::suspendMultithreading() VL_MT_SAFE VL_EXCLUDES(m_mutex)
void V3ThreadPool::resumeMultithreading() VL_MT_SAFE VL_EXCLUDES(m_mutex) void V3ThreadPool::resumeMultithreading() VL_MT_SAFE VL_EXCLUDES(m_mutex)
VL_EXCLUDES(m_stoppedJobsMutex) { VL_EXCLUDES(m_stoppedJobsMutex) {
if (!m_mutex.try_lock()) { v3fatal("Tried to resume thread pool when other thread uses it."); } if (!m_mutex.try_lock()) v3fatal("Tried to resume thread pool when other thread uses it.");
{ {
V3LockGuard lock{m_mutex, std::adopt_lock_t{}}; V3LockGuard lock{m_mutex, std::adopt_lock_t{}};
UASSERT(m_multithreadingSuspended, "Multithreading is not suspended"); UASSERT(m_multithreadingSuspended, "Multithreading is not suspended");
@ -103,7 +103,7 @@ void V3ThreadPool::workerJobLoop(int id) VL_MT_SAFE {
return !m_queue.empty() || m_shutdown || m_stopRequested; return !m_queue.empty() || m_shutdown || m_stopRequested;
}); });
if (m_shutdown) return; // Terminate if requested if (m_shutdown) return; // Terminate if requested
if (stopRequested()) { continue; } if (stopRequested()) continue;
// Get the job // Get the job
UASSERT(!m_queue.empty(), "Job should be available"); UASSERT(!m_queue.empty(), "Job should be available");

View File

@ -307,7 +307,7 @@ public:
if (!V3ThreadPool::s().willExecuteSynchronously()) { if (!V3ThreadPool::s().willExecuteSynchronously()) {
V3ThreadPool::s().m_stoppedJobsMutex.lock(); V3ThreadPool::s().m_stoppedJobsMutex.lock();
if (V3ThreadPool::s().stopRequested()) { V3ThreadPool::s().waitForResumeRequest(); } if (V3ThreadPool::s().stopRequested()) V3ThreadPool::s().waitForResumeRequest();
V3ThreadPool::s().stopOtherThreads(); V3ThreadPool::s().stopOtherThreads();
V3ThreadPool::s().m_exclusiveAccess = true; V3ThreadPool::s().m_exclusiveAccess = true;
} else { } else {

View File

@ -342,7 +342,7 @@ class TraceDeclVisitor final : public VNVisitor {
// Gather cells under this scope // Gather cells under this scope
for (AstNode* stmtp = nodep->modp()->stmtsp(); stmtp; stmtp = stmtp->nextp()) { for (AstNode* stmtp = nodep->modp()->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (AstCell* const cellp = VN_CAST(stmtp, Cell)) { m_entries.emplace_back(cellp); } if (AstCell* const cellp = VN_CAST(stmtp, Cell)) m_entries.emplace_back(cellp);
} }
if (!m_entries.empty()) { if (!m_entries.empty()) {

View File

@ -120,7 +120,7 @@ public:
// Compute the number of MTasks not shared (Hamming distance) // Compute the number of MTasks not shared (Hamming distance)
int cost = 0; int cost = 0;
const size_t size = ExecMTask::numUsedIds(); const size_t size = ExecMTask::numUsedIds();
for (size_t i = 0; i < size; ++i) { cost += m_mTaskIds.at(i) ^ otherp->m_mTaskIds.at(i); } for (size_t i = 0; i < size; ++i) cost += m_mTaskIds.at(i) ^ otherp->m_mTaskIds.at(i);
return cost; return cost;
} }
}; };

View File

@ -1355,7 +1355,7 @@ class WidthVisitor final : public VNVisitor {
} }
} }
void visit(AstCLog2* nodep) override { void visit(AstCLog2* nodep) override {
if (m_vup->prelim()) { iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH); } if (m_vup->prelim()) iterateCheckSizedSelf(nodep, "LHS", nodep->lhsp(), SELF, BOTH);
} }
void visit(AstPow* nodep) override { void visit(AstPow* nodep) override {
// Pow is special, output sign only depends on LHS sign, but // Pow is special, output sign only depends on LHS sign, but

View File

@ -153,7 +153,7 @@ int main(int argc, char** argv) {
V3Error::abortIfWarnings(); V3Error::abortIfWarnings();
if (top.opt.unlink()) { if (top.opt.unlink()) {
const VlStringSet& readFiles = top.opt.readFiles(); const VlStringSet& readFiles = top.opt.readFiles();
for (const auto& filename : readFiles) { unlink(filename.c_str()); } for (const auto& filename : readFiles) unlink(filename.c_str());
} }
} }

View File

@ -104,7 +104,7 @@ public:
// CONSTRUCTORS // CONSTRUCTORS
VlcTests() = default; VlcTests() = default;
~VlcTests() { ~VlcTests() {
for (auto it = begin(); it != end(); ++it) { VL_DO_CLEAR(delete *it, *it = nullptr); } for (auto it = begin(); it != end(); ++it) VL_DO_CLEAR(delete *it, *it = nullptr);
} }
// METHODS // METHODS

View File

@ -218,7 +218,7 @@ public:
m_pinNum = 1; m_pinNum = 1;
} }
void pinPop(FileLine* fl) { void pinPop(FileLine* fl) {
if (VL_UNCOVERABLE(m_pinStack.empty())) { fl->v3fatalSrc("Underflow of pin stack"); } if (VL_UNCOVERABLE(m_pinStack.empty())) fl->v3fatalSrc("Underflow of pin stack");
m_pinNum = m_pinStack.top(); m_pinNum = m_pinStack.top();
m_pinStack.pop(); m_pinStack.pop();
} }
@ -7488,7 +7488,7 @@ vltOffFront<errcodeen>:
| yVLT_LINT_OFF { $$ = V3ErrorCode::I_LINT; } | yVLT_LINT_OFF { $$ = V3ErrorCode::I_LINT; }
| yVLT_LINT_OFF yVLT_D_RULE idAny | yVLT_LINT_OFF yVLT_D_RULE idAny
{ const char *codemsg = (*$3).c_str(); { const char *codemsg = (*$3).c_str();
if (V3ErrorCode::unusedMsg(codemsg)) {$$ = V3ErrorCode::I_UNUSED; } if (V3ErrorCode::unusedMsg(codemsg)) $$ = V3ErrorCode::I_UNUSED;
else {$$ = V3ErrorCode{codemsg}; } else {$$ = V3ErrorCode{codemsg}; }
if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown error code: '" << *$3 << "'"); } } if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown error code: '" << *$3 << "'"); } }
; ;
@ -7500,7 +7500,7 @@ vltOnFront<errcodeen>:
| yVLT_LINT_ON { $$ = V3ErrorCode::I_LINT; } | yVLT_LINT_ON { $$ = V3ErrorCode::I_LINT; }
| yVLT_LINT_ON yVLT_D_RULE idAny | yVLT_LINT_ON yVLT_D_RULE idAny
{ const char *codemsg = (*$3).c_str(); { const char *codemsg = (*$3).c_str();
if (V3ErrorCode::unusedMsg(codemsg)) {$$ = V3ErrorCode::I_UNUSED; } if (V3ErrorCode::unusedMsg(codemsg)) $$ = V3ErrorCode::I_UNUSED;
else {$$ = V3ErrorCode{codemsg}; } else {$$ = V3ErrorCode{codemsg}; }
if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown error code: '" << *$3 << "'"); } } if ($$ == V3ErrorCode::EC_ERROR) { $1->v3error("Unknown error code: '" << *$3 << "'"); } }
; ;