Add "yosys -w" for suppressing warnings

This commit is contained in:
Clifford Wolf 2017-02-12 11:11:00 +01:00
parent cdb6ceb8c6
commit 828303791b
3 changed files with 34 additions and 11 deletions

View File

@ -219,7 +219,11 @@ int main(int argc, char **argv)
printf(" Use 'ALL' as <header_id> to dump at every header.\n"); printf(" Use 'ALL' as <header_id> to dump at every header.\n");
printf("\n"); printf("\n");
printf(" -W regex\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("\n");
printf(" -V\n"); printf(" -V\n");
printf(" print version information and exit\n"); printf(" print version information and exit\n");
@ -241,7 +245,7 @@ int main(int argc, char **argv)
} }
int opt; 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) switch (opt)
{ {
@ -329,6 +333,12 @@ int main(int argc, char **argv)
std::regex_constants::optimize | std::regex_constants::optimize |
std::regex_constants::egrep)); std::regex_constants::egrep));
break; 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': case 'D':
{ {
auto args = split_tokens(optarg, ":"); auto args = split_tokens(optarg, ":");

View File

@ -41,7 +41,7 @@ YOSYS_NAMESPACE_BEGIN
std::vector<FILE*> log_files; std::vector<FILE*> log_files;
std::vector<std::ostream*> log_streams; std::vector<std::ostream*> log_streams;
std::map<std::string, std::set<std::string>> log_hdump; 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; bool log_hdump_all = false;
FILE *log_errfile = NULL; FILE *log_errfile = NULL;
SHA1 *log_hasher = 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) void logv_warning(const char *format, va_list ap)
{ {
if (log_errfile != NULL && !log_quiet_warnings) std::string message = vstringf(format, ap);
log_files.push_back(log_errfile); bool suppressed = false;
log("Warning: "); for (auto &re : log_nowarn_regexes)
logv(format, ap); if (std::regex_search(message, re))
log_flush(); suppressed = true;
if (log_errfile != NULL && !log_quiet_warnings) if (suppressed)
log_files.pop_back(); {
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) void logv_error(const char *format, va_list ap)

View File

@ -49,7 +49,7 @@ struct log_cmd_error_exception { };
extern std::vector<FILE*> log_files; extern std::vector<FILE*> log_files;
extern std::vector<std::ostream*> log_streams; extern std::vector<std::ostream*> log_streams;
extern std::map<std::string, std::set<std::string>> log_hdump; 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 bool log_hdump_all;
extern FILE *log_errfile; extern FILE *log_errfile;
extern SHA1 *log_hasher; extern SHA1 *log_hasher;