mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-03 18:00:24 +00:00
Make log_file_error() use variadic templates.
This commit is contained in:
parent
c368ce99c1
commit
5951d9d303
2 changed files with 14 additions and 12 deletions
|
@ -361,20 +361,16 @@ static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log_formatted_file_error(std::string_view filename, int lineno, std::string str)
|
||||||
|
{
|
||||||
|
std::string prefix = stringf("%s:%d: ERROR: ", filename, lineno);
|
||||||
|
log_error_with_prefix(prefix, str);
|
||||||
|
}
|
||||||
|
|
||||||
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: ",
|
log_formatted_file_error(filename, lineno, vstringf(format, ap));
|
||||||
filename.c_str(), lineno);
|
|
||||||
log_error_with_prefix(prefix, vstringf(format, ap));
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_file_error(const string &filename, int lineno,
|
|
||||||
const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
logv_file_error(filename, lineno, format, ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_experimental(const std::string &str)
|
void log_experimental(const std::string &str)
|
||||||
|
|
|
@ -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_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));
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -188,6 +187,13 @@ template <typename... Args>
|
||||||
log_formatted_error(fmt.format(args...));
|
log_formatted_error(fmt.format(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[noreturn]] void log_formatted_file_error(std::string_view filename, int lineno, std::string str);
|
||||||
|
template <typename... Args>
|
||||||
|
[[noreturn]] void log_file_error(std::string_view filename, int lineno, FmtString<TypeIdentity<Args>...> fmt, Args... args)
|
||||||
|
{
|
||||||
|
log_formatted_file_error(filename, lineno, 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