From ad4ef8b775f67c2394779c08bb519cf0db51c0da Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 12 Sep 2025 06:01:32 +0000 Subject: [PATCH] Make AstNode::input_error use C++ stringf machinery --- frontends/ast/ast.cc | 6 ++---- frontends/ast/ast.h | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index 313161fc3..9af355109 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1922,11 +1922,9 @@ void AstModule::loadconfig() const flag_autowire = autowire; } -void AstNode::input_error(const char *format, ...) const +void AstNode::formatted_input_error(std::string str) const { - va_list ap; - va_start(ap, format); - logv_file_error(*location.begin.filename, location.begin.line, format, ap); + log_formatted_file_error(*location.begin.filename, location.begin.line, std::move(str)); } YOSYS_NAMESPACE_END diff --git a/frontends/ast/ast.h b/frontends/ast/ast.h index fdf4d1ec9..fd8ecddd7 100644 --- a/frontends/ast/ast.h +++ b/frontends/ast/ast.h @@ -378,7 +378,12 @@ namespace AST AstNode *get_struct_member() const; // helper to print errors from simplify/genrtlil code - [[noreturn]] void input_error(const char *format, ...) const YS_ATTRIBUTE(format(printf, 2, 3)); + [[noreturn]] void formatted_input_error(std::string str) const; + template + [[noreturn]] void input_error(FmtString...> fmt, const Args &... args) const + { + formatted_input_error(fmt.format(args...)); + } }; // process an AST tree (ast must point to an AST_DESIGN node) and generate RTLIL code