Add "yosys -w" for suppressing warnings
authorClifford Wolf <clifford@clifford.at>
Sun, 12 Feb 2017 10:11:00 +0000 (11:11 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 12 Feb 2017 10:11:00 +0000 (11:11 +0100)
kernel/driver.cc
kernel/log.cc
kernel/log.h

index 3652ff4f1eb513384731d3e0cd3ce88f50df75bd..7d714d079ce4de0df41e1d66c3d216a0e29372a8 100644 (file)
@@ -219,7 +219,11 @@ int main(int argc, char **argv)
                printf("        Use 'ALL' as <header_id> 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, ":");
index 956d93fd1ae73447b28bf9634b98bf1fad915501..c7240d54035279ef726a0a91c9e39e41f11ef478 100644 (file)
@@ -41,7 +41,7 @@ YOSYS_NAMESPACE_BEGIN
 std::vector<FILE*> log_files;
 std::vector<std::ostream*> log_streams;
 std::map<std::string, std::set<std::string>> log_hdump;
-std::vector<std::regex> log_warn_regexes;
+std::vector<std::regex> 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)
index 34b8ac3a57e7b18e55b668ca895d8e985937b9c1..34c30901619b54fb43f0716494c923c3240992d4 100644 (file)
@@ -49,7 +49,7 @@ struct log_cmd_error_exception { };
 extern std::vector<FILE*> log_files;
 extern std::vector<std::ostream*> log_streams;
 extern std::map<std::string, std::set<std::string>> log_hdump;
-extern std::vector<std::regex> log_warn_regexes;
+extern std::vector<std::regex> log_warn_regexes, log_nowarn_regexes;
 extern bool log_hdump_all;
 extern FILE *log_errfile;
 extern SHA1 *log_hasher;