mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-03 18:00:24 +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)
|
for (auto &re : log_werror_regexes)
|
||||||
if (std::regex_search(message, re))
|
if (std::regex_search(message, re))
|
||||||
log_error("%s", message.c_str());
|
log_error("%s", message);
|
||||||
|
|
||||||
bool warning_match = false;
|
bool warning_match = false;
|
||||||
for (auto &item : log_expect_warning)
|
for (auto &item : log_expect_warning)
|
||||||
|
@ -314,8 +314,7 @@ void log_formatted_file_info(std::string_view filename, int lineno, std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
[[noreturn]]
|
[[noreturn]]
|
||||||
static void logv_error_with_prefix(const char *prefix,
|
static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||||
const char *format, va_list ap)
|
|
||||||
{
|
{
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
auto backup_log_files = log_files;
|
auto backup_log_files = log_files;
|
||||||
|
@ -332,8 +331,8 @@ static void logv_error_with_prefix(const char *prefix,
|
||||||
if (f == stdout)
|
if (f == stdout)
|
||||||
f = stderr;
|
f = stderr;
|
||||||
|
|
||||||
log_last_error = vstringf(format, ap);
|
log_last_error = std::move(str);
|
||||||
log("%s%s", prefix, log_last_error.c_str());
|
log("%s%s", prefix, log_last_error);
|
||||||
log_flush();
|
log_flush();
|
||||||
|
|
||||||
log_make_debug = bak_log_make_debug;
|
log_make_debug = bak_log_make_debug;
|
||||||
|
@ -362,18 +361,12 @@ static void logv_error_with_prefix(const char *prefix,
|
||||||
#endif
|
#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,
|
void logv_file_error(const string &filename, int lineno,
|
||||||
const char *format, va_list ap)
|
const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
std::string prefix = stringf("%s:%d: ERROR: ",
|
std::string prefix = stringf("%s:%d: ERROR: ",
|
||||||
filename.c_str(), lineno);
|
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,
|
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;
|
log_error_with_prefix("ERROR: ", std::move(str));
|
||||||
va_start(ap, format);
|
|
||||||
logv_error(format, ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_cmd_error(const char *format, ...)
|
void log_cmd_error(const char *format, ...)
|
||||||
|
@ -424,7 +415,7 @@ void log_cmd_error(const char *format, ...)
|
||||||
throw log_cmd_error_exception();
|
throw log_cmd_error_exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
logv_error(format, ap);
|
log_formatted_error(vstringf(format, ap));
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_spacer()
|
void log_spacer()
|
||||||
|
|
|
@ -124,7 +124,6 @@ extern int log_debug_suppressed;
|
||||||
void set_verific_logging(void (*cb)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg));
|
void set_verific_logging(void (*cb)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg));
|
||||||
extern void (*log_verific_callback)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg);
|
extern void (*log_verific_callback)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg);
|
||||||
|
|
||||||
[[noreturn]] void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
|
||||||
[[noreturn]] void log_file_error(const string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
[[noreturn]] void log_file_error(const string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
||||||
[[noreturn]] void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
[[noreturn]] void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||||
|
|
||||||
|
@ -182,6 +181,13 @@ void log_file_info(std::string_view filename, int lineno, FmtString<TypeIdentity
|
||||||
log_formatted_file_info(filename, lineno, fmt.format(args...));
|
log_formatted_file_info(filename, lineno, fmt.format(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[noreturn]] void log_formatted_error(std::string str);
|
||||||
|
template <typename... Args>
|
||||||
|
[[noreturn]] void log_error(FmtString<TypeIdentity<Args>...> fmt, Args... args)
|
||||||
|
{
|
||||||
|
log_formatted_error(fmt.format(args...));
|
||||||
|
}
|
||||||
|
|
||||||
static inline void log_suppressed() {
|
static inline void log_suppressed() {
|
||||||
if (log_debug_suppressed && !log_make_debug) {
|
if (log_debug_suppressed && !log_make_debug) {
|
||||||
log("<suppressed ~%d debug messages>\n", log_debug_suppressed);
|
log("<suppressed ~%d debug messages>\n", log_debug_suppressed);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue