Internals: Add new VL_RESTORER flavours (#7866)

Restrict VL_RESTORER to be usable only with trivially copyable types.
Introduce VL_RESTORER_COPY and VL_RESTORER_CLEAR, which are more
efficient versions usable for non trivially copyable types.

VL_RESTORER_COPY semantically behaves the same as VL_RESTORER, but only
does one copy at initialization, and on scope exit restores via a move.

VL_RESTORER_CLEAR swaps the variable with an new one constructed via
the no-args constructor (e.g. empty collection), which does not require
any copying at any point.

Static assertions enforce picking one of the new flavours when copying
might be expensive.
This commit is contained in:
Geza Lore
2026-07-04 17:27:07 +01:00
committed by GitHub
parent 83eb54ec7e
commit 566f4e6efc
24 changed files with 180 additions and 148 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ class InlineIntfRefVisitor final : public VNVisitor {
// VISITORS
void visit(AstNetlist* nodep) override { iterateChildren(nodep->topModulep()); }
void visit(AstCell* nodep) override {
VL_RESTORER(m_scope);
VL_RESTORER_COPY(m_scope);
if (m_scope.empty()) {
m_scope = nodep->name();
} else {