3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-10 11:41:26 +00:00

Make ID() macro return a reference to the underlying IdString instead of copying it

Lambda return type deduction infers `IdString` here.
This commit is contained in:
Robert O'Callahan 2025-09-02 02:44:02 +00:00 committed by Emil J. Tywoniak
parent b2ccfb2d0e
commit ddf7ba5a34

View file

@ -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;' <filename>
//
#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;