Fix some errors exceeding the --error-limit

This commit is contained in:
Wilson Snyder 2025-05-11 22:36:40 -04:00
parent 8100bc64a0
commit ac2313ecb7
2 changed files with 20 additions and 13 deletions

View File

@ -131,14 +131,31 @@ void V3ErrorGuarded::v3errorPrep(V3ErrorCode code) VL_REQUIRES(m_mutex) {
m_errorSuppressed = false;
}
// cppcheck-has-bug-suppress constParameter
void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra)
VL_REQUIRES(m_mutex) {
static bool s_firedTooMany = false;
v3errorEndGuts(sstr, extra);
if (errorLimit() && errorCount() >= errorLimit() && !s_firedTooMany) {
s_firedTooMany = true;
// Recurses here
v3errorEnd((v3errorPrep(V3ErrorCode::EC_FATALMANY),
(v3errorStr() << "Exiting due to too many errors encountered; --error-limit="
<< errorCount() << std::endl),
v3errorStr()));
assert(0); // LCOV_EXCL_LINE
VL_UNREACHABLE;
}
}
// cppcheck-has-bug-suppress constParameter
void V3ErrorGuarded::v3errorEndGuts(std::ostringstream& sstr, const string& extra)
VL_REQUIRES(m_mutex) {
// 'extra' is appended to the message, and is is excluded in check for
// duplicate messages. Currently used for reporting instance name.
#if defined(__COVERITY__) || defined(__cppcheck__)
if (m_errorCode == V3ErrorCode::EC_FATAL) __coverity_panic__(x);
#endif
// Skip suppressed messages
if (m_errorSuppressed
// On debug, show only non default-off warning to prevent pages of warnings

View File

@ -344,6 +344,7 @@ private:
void v3errorPrep(V3ErrorCode code) VL_REQUIRES(m_mutex);
std::ostringstream& v3errorStr() VL_REQUIRES(m_mutex) { return m_errorStr; }
void v3errorEnd(std::ostringstream& sstr, const string& extra = "") VL_REQUIRES(m_mutex);
void v3errorEndGuts(std::ostringstream& sstr, const string& extra) VL_REQUIRES(m_mutex);
public:
V3RecursiveMutex m_mutex; // Make sure only single thread is in class
@ -359,18 +360,7 @@ public:
void vlAbortOrExit() VL_REQUIRES(m_mutex);
void errorContexted(bool flag) VL_REQUIRES(m_mutex) { m_errorContexted = flag; }
void incWarnings() VL_REQUIRES(m_mutex) { ++m_warnCount; }
void incErrors() VL_REQUIRES(m_mutex) {
++m_errCount;
if (errorCount() == errorLimit()) { // Not >= as would otherwise recurse
v3errorEnd(
(v3errorPrep(V3ErrorCode::EC_FATALMANY),
(v3errorStr() << "Exiting due to too many errors encountered; --error-limit="
<< errorCount() << std::endl),
v3errorStr()));
assert(0); // LCOV_EXCL_LINE
VL_UNREACHABLE;
}
}
void incErrors() VL_REQUIRES(m_mutex) { ++m_errCount; }
int errorCount() VL_REQUIRES(m_mutex) { return m_errCount; }
bool pretendError(int errorCode) VL_REQUIRES(m_mutex) { return m_pretendError[errorCode]; }
void pretendError(V3ErrorCode code, bool flag) VL_REQUIRES(m_mutex) {