Change --quiet-exit to also suppress 'Exiting due to N errors'.

This commit is contained in:
Wilson Snyder 2020-03-15 08:09:51 -04:00
parent 81c659957e
commit 5f63b24c50
7 changed files with 47 additions and 25 deletions

View File

@ -5,10 +5,12 @@ The contributors that suggested a given feature are shown in []. Thanks!
* Verilator 4.031 devel
** Add column numbers to errors and warnings.
*** Add column numbers to errors and warnings.
*** Add setting VM_PARALLEL_BUILDS=1 when using --output-split, #2185.
*** Change --quiet-exit to also suppress 'Exiting due to N errors'.
* Verilator 4.030 2020-03-08

View File

@ -1273,7 +1273,8 @@ detailed description.
=item --quiet-exit
When exiting due to an error, do not display the "Command Failed" message.
When exiting due to an error, do not display the "Exiting due to Errors"
nor "Command Failed" messages.
=item --relative-includes

View File

@ -92,30 +92,32 @@ string V3Error::lineStr(const char* filename, int lineno) {
void V3Error::incErrors() {
s_errCount++;
if (errorCount() == errorLimit()) { // Not >= as would otherwise recurse
v3fatal("Exiting due to too many errors encountered; --error-limit="<<errorCount()<<endl);
v3fatalExit("Exiting due to too many errors encountered; --error-limit="
<< errorCount() << endl);
}
}
void V3Error::abortIfWarnings() {
bool exwarn = warnFatal() && warnCount();
if (errorCount() && exwarn) {
v3fatal("Exiting due to "<<std::dec<<errorCount()<<" error(s), "
<<warnCount()<<" warning(s)\n");
v3fatalExit("Exiting due to " << std::dec << errorCount() << " error(s), "
<< warnCount() << " warning(s)\n");
} else if (errorCount()) {
v3fatal("Exiting due to "<<std::dec<<errorCount()<<" error(s)\n");
v3fatalExit("Exiting due to " << std::dec << errorCount() << " error(s)\n");
} else if (exwarn) {
v3fatal("Exiting due to "<<std::dec<<warnCount()<<" warning(s)\n");
v3fatalExit("Exiting due to " << std::dec << warnCount() << " warning(s)\n");
}
}
bool V3Error::isError(V3ErrorCode code, bool supp) {
if (supp) return false;
else if (code==V3ErrorCode::USERINFO) return false;
else if (code==V3ErrorCode::EC_INFO) return false;
else if (code==V3ErrorCode::EC_FATAL) return true;
else if (code==V3ErrorCode::EC_FATALSRC) return true;
else if (code==V3ErrorCode::EC_ERROR) return true;
else if (code<V3ErrorCode::EC_FIRST_WARN
else if (code == V3ErrorCode::USERINFO) return false;
else if (code == V3ErrorCode::EC_INFO) return false;
else if (code == V3ErrorCode::EC_FATAL) return true;
else if (code == V3ErrorCode::EC_FATALEXIT) return true;
else if (code == V3ErrorCode::EC_FATALSRC) return true;
else if (code == V3ErrorCode::EC_ERROR) return true;
else if (code < V3ErrorCode::EC_FIRST_WARN
|| s_pretendError[code]) return true;
else return false;
}
@ -124,11 +126,12 @@ string V3Error::msgPrefix() {
V3ErrorCode code = s_errorCode;
bool supp = s_errorSuppressed;
if (supp) return "-arning-suppressed: ";
else if (code==V3ErrorCode::USERINFO) return "-Info: ";
else if (code==V3ErrorCode::EC_INFO) return "-Info: ";
else if (code==V3ErrorCode::EC_FATAL) return "%Error: ";
else if (code==V3ErrorCode::EC_FATALSRC) return "%Error: Internal Error: ";
else if (code==V3ErrorCode::EC_ERROR) return "%Error: ";
else if (code == V3ErrorCode::USERINFO) return "-Info: ";
else if (code == V3ErrorCode::EC_INFO) return "-Info: ";
else if (code == V3ErrorCode::EC_FATAL) return "%Error: ";
else if (code == V3ErrorCode::EC_FATALEXIT) return "%Error: ";
else if (code == V3ErrorCode::EC_FATALSRC) return "%Error: Internal Error: ";
else if (code == V3ErrorCode::EC_ERROR) return "%Error: ";
else if (isError(code, supp)) return "%Error-"+string(code.ascii())+": ";
else return "%Warning-"+string(code.ascii())+": ";
}
@ -194,7 +197,15 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) {
msg.insert(pos + 1, locationMsg);
}
// Output
std::cerr<<msg;
if (
#ifndef _V3ERROR_NO_GLOBAL_
!(v3Global.opt.quietExit() && s_errorCode == V3ErrorCode::EC_FATALEXIT)
#else
true
#endif
) {
std::cerr << msg;
}
if (!s_errorSuppressed && !(s_errorCode==V3ErrorCode::EC_INFO
|| s_errorCode==V3ErrorCode::USERINFO)) {
if (!s_describedEachWarn[s_errorCode]
@ -222,8 +233,9 @@ void V3Error::v3errorEnd(std::ostringstream& sstr, const string& locationStr) {
}
if (isError(s_errorCode, s_errorSuppressed)) incErrors();
else incWarnings();
if (s_errorCode==V3ErrorCode::EC_FATAL
|| s_errorCode==V3ErrorCode::EC_FATALSRC) {
if (s_errorCode == V3ErrorCode::EC_FATAL
|| s_errorCode == V3ErrorCode::EC_FATALEXIT
|| s_errorCode == V3ErrorCode::EC_FATALSRC) {
static bool inFatal = false;
if (!inFatal) {
inFatal = true;

View File

@ -43,6 +43,7 @@ public:
//
EC_INFO, // General information out
EC_FATAL, // Kill the program
EC_FATALEXIT, // Kill the program, suppress with --quiet-exit
EC_FATALSRC, // Kill the program, for internal source errors
EC_ERROR, // General error out, can't suppress
// Boolean information we track per-line, but aren't errors
@ -134,7 +135,7 @@ public:
const char* ascii() const {
const char* names[] = {
// Leading spaces indicate it can't be disabled.
" MIN", " INFO", " FATAL", " FATALSRC", " ERROR",
" MIN", " INFO", " FATAL", " FATALEXIT", " FATALSRC", " ERROR",
// Boolean
" I_COVERAGE", " I_TRACING", " I_LINT", " I_DEF_NETTYPE_WIRE",
// Errors
@ -307,6 +308,8 @@ inline void v3errorEndFatal(std::ostringstream& sstr) {
#define v3info(msg) v3warnCode(V3ErrorCode::EC_INFO, msg)
#define v3error(msg) v3warnCode(V3ErrorCode::EC_ERROR, msg)
#define v3fatal(msg) v3warnCodeFatal(V3ErrorCode::EC_FATAL, msg)
// Use this instead of fatal() if message gets suppressed with --quiet-exit
#define v3fatalExit(msg) v3warnCodeFatal(V3ErrorCode::EC_FATALEXIT, msg)
// Use this instead of fatal() to mention the source code line.
#define v3fatalSrc(msg) v3warnCodeFatal(V3ErrorCode::EC_FATALSRC, __FILE__<<":"<<std::dec<<__LINE__<<": "<<msg)
// Use this when normal v3fatal is called in static method that overrides fileline.

View File

@ -778,6 +778,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if ( onoff (sw, "-public", flag/*ref*/)) { m_public = flag; }
else if ( onoff (sw, "-public-flat-rw", flag/*ref*/) ) { m_publicFlatRW = flag; v3Global.dpi(true); }
else if (!strncmp(sw, "-pvalue+", strlen("-pvalue+"))) { addParameter(string(sw+strlen("-pvalue+")), false); }
else if ( onoff (sw, "-quiet-exit", flag/*ref*/)) { m_quietExit = flag; }
else if ( onoff (sw, "-relative-cfuncs", flag/*ref*/)) { m_relativeCFuncs = flag; }
else if ( onoff (sw, "-relative-includes", flag/*ref*/)) { m_relativeIncludes = flag; }
else if ( onoff (sw, "-report-unoptflat", flag/*ref*/)) { m_reportUnoptflat = flag; }
@ -1484,6 +1485,7 @@ V3Options::V3Options() {
m_preprocNoLine = false;
m_public = false;
m_publicFlatRW = false;
m_quietExit = false;
m_relativeCFuncs = true;
m_relativeIncludes = false;
m_reportUnoptflat = false;

View File

@ -180,6 +180,7 @@ class V3Options {
bool m_protectIds; // main switch: --protect-ids
bool m_public; // main switch: --public
bool m_publicFlatRW; // main switch: --public-flat-rw
bool m_quietExit; // main switch: --quiet-exit
bool m_relativeCFuncs; // main switch: --relative-cfuncs
bool m_relativeIncludes; // main switch: --relative-includes
bool m_reportUnoptflat; // main switch: --report-unoptflat
@ -373,6 +374,7 @@ class V3Options {
bool lintOnly() const { return m_lintOnly; }
bool ignc() const { return m_ignc; }
bool inhibitSim() const { return m_inhibitSim; }
bool quietExit() const { return m_quietExit; }
bool relativeCFuncs() const { return m_relativeCFuncs; }
bool reportUnoptflat() const { return m_reportUnoptflat; }
bool vpi() const { return m_vpi; }

View File

@ -16,10 +16,10 @@ top_filename("t/t_file_does_not_exist.v");
compile(
v_flags2 => ["--quiet-exit"],
fails => 1,
expect =>
'%Error: Exiting due to \d+ error\(s\)
((?!Command Failed).)*$',
);
file_grep_not("$Self->{obj_dir}/vlt_compile.log", qr/Exiting due to/);
file_grep_not("$Self->{obj_dir}/vlt_compile.log", qr/Command Failed/);
ok(1);
1;