mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-04 18:30:25 +00:00
Make log_error() use variadic templates.
This commit is contained in:
parent
d173c2c51f
commit
c368ce99c1
2 changed files with 15 additions and 18 deletions
|
@ -267,7 +267,7 @@ void log_formatted_warning(std::string_view prefix, std::string message)
|
|||
|
||||
for (auto &re : log_werror_regexes)
|
||||
if (std::regex_search(message, re))
|
||||
log_error("%s", message.c_str());
|
||||
log_error("%s", message);
|
||||
|
||||
bool warning_match = false;
|
||||
for (auto &item : log_expect_warning)
|
||||
|
@ -314,8 +314,7 @@ void log_formatted_file_info(std::string_view filename, int lineno, std::string
|
|||
}
|
||||
|
||||
[[noreturn]]
|
||||
static void logv_error_with_prefix(const char *prefix,
|
||||
const char *format, va_list ap)
|
||||
static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
auto backup_log_files = log_files;
|
||||
|
@ -332,8 +331,8 @@ static void logv_error_with_prefix(const char *prefix,
|
|||
if (f == stdout)
|
||||
f = stderr;
|
||||
|
||||
log_last_error = vstringf(format, ap);
|
||||
log("%s%s", prefix, log_last_error.c_str());
|
||||
log_last_error = std::move(str);
|
||||
log("%s%s", prefix, log_last_error);
|
||||
log_flush();
|
||||
|
||||
log_make_debug = bak_log_make_debug;
|
||||
|
@ -362,18 +361,12 @@ static void logv_error_with_prefix(const char *prefix,
|
|||
#endif
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
static void logv_error(const char *format, va_list ap)
|
||||
{
|
||||
logv_error_with_prefix("ERROR: ", format, ap);
|
||||
}
|
||||
|
||||
void logv_file_error(const string &filename, int lineno,
|
||||
const char *format, va_list ap)
|
||||
{
|
||||
std::string prefix = stringf("%s:%d: ERROR: ",
|
||||
filename.c_str(), lineno);
|
||||
logv_error_with_prefix(prefix.c_str(), format, ap);
|
||||
log_error_with_prefix(prefix, vstringf(format, ap));
|
||||
}
|
||||
|
||||
void log_file_error(const string &filename, int lineno,
|
||||
|
@ -392,11 +385,9 @@ void log_experimental(const std::string &str)
|
|||
}
|
||||
}
|
||||
|
||||
void log_error(const char *format, ...)
|
||||
void log_formatted_error(std::string str)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv_error(format, ap);
|
||||
log_error_with_prefix("ERROR: ", std::move(str));
|
||||
}
|
||||
|
||||
void log_cmd_error(const char *format, ...)
|
||||
|
@ -424,7 +415,7 @@ void log_cmd_error(const char *format, ...)
|
|||
throw log_cmd_error_exception();
|
||||
}
|
||||
|
||||
logv_error(format, ap);
|
||||
log_formatted_error(vstringf(format, ap));
|
||||
}
|
||||
|
||||
void log_spacer()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue