From ddf7ba5a34619eda291d9510f6da4f65bffbcf4f Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 2 Sep 2025 02:44:02 +0000 Subject: [PATCH] Make `ID()` macro return a reference to the underlying `IdString` instead of copying it Lambda return type deduction infers `IdString` here. --- kernel/yosys_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index bc92e7869..943aa4f05 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -285,7 +285,7 @@ RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std: // // sed -i.orig -r 's/"\\\\([a-zA-Z0-9_]+)"/ID(\1)/g; s/"(\$[a-zA-Z0-9_]+)"/ID(\1)/g;' // -#define ID(_id) ([]() { const char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \ +#define ID(_id) ([]() -> const RTLIL::IdString & { const char *p = "\\" #_id, *q = p[1] == '$' ? p+1 : p; \ static const YOSYS_NAMESPACE_PREFIX RTLIL::IdString id(q); return id; })() namespace ID = RTLIL::ID;