error/warn
This commit is contained in:
parent
078d69fc8d
commit
ee86a30338
|
|
@ -47,7 +47,6 @@ public:
|
|||
va_list args);
|
||||
void print(const string *str);
|
||||
void print(const string &str);
|
||||
virtual void flush() {}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
@ -55,6 +54,9 @@ public:
|
|||
virtual void warn(int id,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
virtual void vwarn(int id,
|
||||
const char *fmt,
|
||||
va_list args);
|
||||
// Report warning in a file.
|
||||
virtual void fileWarn(int id,
|
||||
const char *filename,
|
||||
|
|
@ -65,11 +67,14 @@ public:
|
|||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
va_list args);
|
||||
va_list args);
|
||||
|
||||
virtual void error(int id,
|
||||
const char *fmt, ...)
|
||||
__attribute__((format (printf, 3, 4)));
|
||||
virtual void verror(int id,
|
||||
const char *fmt,
|
||||
va_list args);
|
||||
// Report error in a file.
|
||||
virtual void fileError(int id,
|
||||
const char *filename,
|
||||
|
|
@ -80,7 +85,7 @@ public:
|
|||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
va_list args);
|
||||
va_list args);
|
||||
|
||||
// Critical.
|
||||
// Report error condition that should not be possible or that prevents execution.
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ libertyParseError(const char *fmt, ...)
|
|||
va_list args;
|
||||
va_start(args, fmt);
|
||||
sta::liberty_report->vfileError(25, sta::liberty_filename, sta::liberty_line,
|
||||
fmt, args);
|
||||
fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4399,7 +4399,7 @@ LibertyReader::libWarn(int id,
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
report_->vfileWarn(id, filename_, stmt->line(), fmt, args);
|
||||
report_->fileWarn(id, filename_, stmt->line(), fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
|
|
|||
38
tcl/StaTcl.i
38
tcl/StaTcl.i
|
|
@ -1943,6 +1943,44 @@ git_sha1()
|
|||
return STA_GIT_SHA1;
|
||||
}
|
||||
|
||||
void
|
||||
report_error(int id,
|
||||
const char *msg)
|
||||
{
|
||||
Sta::sta()->report()->error(id, "%s", msg);
|
||||
}
|
||||
|
||||
void
|
||||
report_file_error(int id,
|
||||
const char *filename,
|
||||
int line,
|
||||
const char *msg)
|
||||
{
|
||||
Sta::sta()->report()->error(id, filename, line, "%s", msg);
|
||||
}
|
||||
|
||||
void
|
||||
report_warn(int id,
|
||||
const char *msg)
|
||||
{
|
||||
Sta::sta()->report()->warn(id, "%s", msg);
|
||||
}
|
||||
|
||||
void
|
||||
report_file_warn(int id,
|
||||
const char *filename,
|
||||
int line,
|
||||
const char *msg)
|
||||
{
|
||||
Sta::sta()->report()->fileWarn(id, filename, line, "%s", msg);
|
||||
}
|
||||
|
||||
void
|
||||
report(const char *msg)
|
||||
{
|
||||
Sta::sta()->report()->print(msg);
|
||||
}
|
||||
|
||||
void
|
||||
fflush()
|
||||
{
|
||||
|
|
|
|||
14
tcl/Util.tcl
14
tcl/Util.tcl
|
|
@ -251,13 +251,13 @@ proc show_cmd_args { cmd } {
|
|||
|
||||
################################################################
|
||||
|
||||
proc sta_warn { id msg } {
|
||||
proc sta_warn { msg_id msg } {
|
||||
variable sdc_file
|
||||
variable sdc_line
|
||||
if { [info exists sdc_file] } {
|
||||
puts "Warning: [file tail $sdc_file], $sdc_line $msg"
|
||||
report_file_warn $msg_id [file tail $sdc_file] $sdc_line $msg
|
||||
} else {
|
||||
puts "Warning: $msg"
|
||||
report_warn $msg_id $msg
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,17 +265,17 @@ proc sta_error { id msg } {
|
|||
variable sdc_file
|
||||
variable sdc_line
|
||||
if { [info exists sdc_file] } {
|
||||
error "Error: [file tail $sdc_file], $sdc_line $msg"
|
||||
error "Error: [file tail $sdc_file] line $sdc_line, $msg"
|
||||
} else {
|
||||
error "Error: $msg"
|
||||
}
|
||||
}
|
||||
|
||||
proc sta_warn_error { id warn_error msg } {
|
||||
proc sta_warn_error { msg_id warn_error msg } {
|
||||
if { $warn_error == "warn" } {
|
||||
sta_warn $id $msg
|
||||
sta_warn $msg_id $msg
|
||||
} else {
|
||||
sta_error $id $msg
|
||||
sta_error $$msg_id $msg
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,17 @@ Report::warn(int /* id */,
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
Report::vwarn(int /* id */,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
printToBuffer("Warning: ");
|
||||
printToBufferAppend(fmt, args);
|
||||
printToBufferAppend("\n");
|
||||
printBuffer();
|
||||
}
|
||||
|
||||
void
|
||||
Report::fileWarn(int /* id */,
|
||||
const char *filename,
|
||||
|
|
@ -167,7 +178,7 @@ Report::fileWarn(int /* id */,
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printToBuffer("Warning: %s, line %d ", filename, line);
|
||||
printToBuffer("Warning: %s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
printToBufferAppend("\n");
|
||||
printBuffer();
|
||||
|
|
@ -179,9 +190,9 @@ Report::vfileWarn(int /* id */,
|
|||
const char *filename,
|
||||
int line,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
va_list args)
|
||||
{
|
||||
printToBuffer("Warning: %s, line %d ", filename, line);
|
||||
printToBuffer("Warning: %s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
printToBufferAppend("\n");
|
||||
printBuffer();
|
||||
|
|
@ -193,7 +204,6 @@ void
|
|||
Report::error(int /* id */,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
flush();
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
// No prefix msg, no \n.
|
||||
|
|
@ -202,6 +212,16 @@ Report::error(int /* id */,
|
|||
throw ExceptionMsg(buffer_);
|
||||
}
|
||||
|
||||
void
|
||||
Report::verror(int /* id */,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
// No prefix msg, no \n.
|
||||
printToBuffer(fmt, args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
}
|
||||
|
||||
void
|
||||
Report::fileError(int /* id */,
|
||||
const char *filename,
|
||||
|
|
@ -209,11 +229,10 @@ Report::fileError(int /* id */,
|
|||
const char *fmt,
|
||||
...)
|
||||
{
|
||||
flush();
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
// No prefix msg, no \n.
|
||||
printToBuffer("%s, line %d ", filename, line);
|
||||
printToBuffer("%s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
va_end(args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
|
|
@ -226,9 +245,8 @@ Report::vfileError(int /* id */,
|
|||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
flush();
|
||||
// No prefix msg, no \n.
|
||||
printToBuffer("%s, line %d ", filename, line);
|
||||
printToBuffer("%s line %d, ", filename, line);
|
||||
printToBufferAppend(fmt, args);
|
||||
throw ExceptionMsg(buffer_);
|
||||
}
|
||||
|
|
@ -258,7 +276,7 @@ Report::fileCritical(int /* id */,
|
|||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printToBuffer("Critical: %s, line %d ", filename, line, fmt, args);
|
||||
printToBuffer("Critical: %s line %d, ", filename, line, fmt, args);
|
||||
printToBufferAppend(fmt, args);
|
||||
printToBufferAppend("\n");
|
||||
va_end(args);
|
||||
|
|
|
|||
|
|
@ -2242,10 +2242,8 @@ void verilogFlushBuffer();
|
|||
int
|
||||
VerilogParse_error(const char *msg)
|
||||
{
|
||||
sta::verilog_reader->report()->fileError(164,
|
||||
sta::verilog_reader->filename(),
|
||||
sta::verilog_reader->line(),
|
||||
"%s.\n", msg);
|
||||
sta::verilog_reader->report()->fileError(164, sta::verilog_reader->filename(),
|
||||
sta::verilog_reader->line(), "%s", msg);
|
||||
verilogFlushBuffer();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue