From: Clifford Wolf Date: Thu, 27 Jul 2017 10:17:04 +0000 (+0200) Subject: Add log_warning_noprefix() API, Use for Verific warnings and errors X-Git-Tag: yosys-0.8~364 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2336d5508b29b607044f86676db98584b2b04f71;p=yosys.git Add log_warning_noprefix() API, Use for Verific warnings and errors --- diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 4f8ea92ef..5f7d973a9 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -77,7 +77,7 @@ void msg_func(msg_type_t msg_type, const char *message_id, linefile_type linefil message += vstringf(msg, args); if (msg_type == VERIFIC_ERROR || msg_type == VERIFIC_WARNING || msg_type == VERIFIC_PROGRAM_ERROR) - log_warning("%s\n", message.c_str()); + log_warning_noprefix("%s\n", message.c_str()); else log("%s\n", message.c_str()); } diff --git a/kernel/log.cc b/kernel/log.cc index 3768922cd..7be95204b 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -227,6 +227,32 @@ void logv_warning(const char *format, va_list ap) } } +void logv_warning_noprefix(const char *format, va_list ap) +{ + std::string message = vstringf(format, ap); + bool suppressed = false; + + for (auto &re : log_nowarn_regexes) + if (std::regex_search(message, re)) + suppressed = true; + + if (suppressed) + { + log("%s", message.c_str()); + } + else + { + if (log_errfile != NULL && !log_quiet_warnings) + log_files.push_back(log_errfile); + + log("%s", message.c_str()); + log_flush(); + + if (log_errfile != NULL && !log_quiet_warnings) + log_files.pop_back(); + } +} + void logv_error(const char *format, va_list ap) { #ifdef EMSCRIPTEN @@ -282,6 +308,14 @@ void log_warning(const char *format, ...) va_end(ap); } +void log_warning_noprefix(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + logv_warning_noprefix(format, ap); + va_end(ap); +} + void log_error(const char *format, ...) { va_list ap; diff --git a/kernel/log.h b/kernel/log.h index 6cae4431d..e27dafab9 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -65,11 +65,13 @@ extern void (*log_error_atexit)(); void logv(const char *format, va_list ap); void logv_header(RTLIL::Design *design, const char *format, va_list ap); void logv_warning(const char *format, va_list ap); +void logv_warning_noprefix(const char *format, va_list ap); YS_NORETURN void logv_error(const char *format, va_list ap) YS_ATTRIBUTE(noreturn); void log(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2)); void log_header(RTLIL::Design *design, const char *format, ...) YS_ATTRIBUTE(format(printf, 2, 3)); void log_warning(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2)); +void log_warning_noprefix(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2)); YS_NORETURN void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2), noreturn); YS_NORETURN void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2), noreturn);