From 828303791b5f4a50a52d4749be42caac9819bf2a Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 12 Feb 2017 11:11:00 +0100 Subject: [PATCH] Add "yosys -w" for suppressing warnings --- kernel/driver.cc | 14 ++++++++++++-- kernel/log.cc | 29 +++++++++++++++++++++-------- kernel/log.h | 2 +- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/kernel/driver.cc b/kernel/driver.cc index 3652ff4f1..7d714d079 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -219,7 +219,11 @@ int main(int argc, char **argv) printf(" Use 'ALL' as to dump at every header.\n"); printf("\n"); printf(" -W regex\n"); - printf(" print a warning for all log messages matching the regex \n"); + printf(" print a warning for all log messages matching the regex.\n"); + printf("\n"); + printf(" -w regex\n"); + printf(" if a warning message matches the regex, it is printes as regular\n"); + printf(" message instead.\n"); printf("\n"); printf(" -V\n"); printf(" print version information and exit\n"); @@ -241,7 +245,7 @@ int main(int argc, char **argv) } int opt; - while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:D:")) != -1) + while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:D:")) != -1) { switch (opt) { @@ -329,6 +333,12 @@ int main(int argc, char **argv) std::regex_constants::optimize | std::regex_constants::egrep)); break; + case 'w': + log_nowarn_regexes.push_back(std::regex(optarg, + std::regex_constants::nosubs | + std::regex_constants::optimize | + std::regex_constants::egrep)); + break; case 'D': { auto args = split_tokens(optarg, ":"); diff --git a/kernel/log.cc b/kernel/log.cc index 956d93fd1..c7240d540 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -41,7 +41,7 @@ YOSYS_NAMESPACE_BEGIN std::vector log_files; std::vector log_streams; std::map> log_hdump; -std::vector log_warn_regexes; +std::vector log_warn_regexes, log_nowarn_regexes; bool log_hdump_all = false; FILE *log_errfile = NULL; SHA1 *log_hasher = NULL; @@ -202,15 +202,28 @@ void logv_header(RTLIL::Design *design, const char *format, va_list ap) void logv_warning(const char *format, va_list ap) { - if (log_errfile != NULL && !log_quiet_warnings) - log_files.push_back(log_errfile); + std::string message = vstringf(format, ap); + bool suppressed = false; - log("Warning: "); - logv(format, ap); - log_flush(); + for (auto &re : log_nowarn_regexes) + if (std::regex_search(message, re)) + suppressed = true; - if (log_errfile != NULL && !log_quiet_warnings) - log_files.pop_back(); + if (suppressed) + { + log("Suppressed warning: %s", message.c_str()); + } + else + { + if (log_errfile != NULL && !log_quiet_warnings) + log_files.push_back(log_errfile); + + log("Warning: %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) diff --git a/kernel/log.h b/kernel/log.h index 34b8ac3a5..34c309016 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -49,7 +49,7 @@ struct log_cmd_error_exception { }; extern std::vector log_files; extern std::vector log_streams; extern std::map> log_hdump; -extern std::vector log_warn_regexes; +extern std::vector log_warn_regexes, log_nowarn_regexes; extern bool log_hdump_all; extern FILE *log_errfile; extern SHA1 *log_hasher; -- 2.30.2