mirror of
https://github.com/verilator/verilator.git
synced 2026-09-07 01:52:17 +02:00
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:
+2
-2
@@ -114,7 +114,7 @@ class ClassVisitor final : public VNVisitor {
|
||||
classScopep->aboveScopep(), classScopep->aboveCellp()};
|
||||
packagep->addStmtsp(scopep);
|
||||
// Iterate
|
||||
VL_RESTORER(m_prefix);
|
||||
VL_RESTORER_CLEAR(m_prefix);
|
||||
VL_RESTORER(m_classPackagep);
|
||||
VL_RESTORER(m_classScopep);
|
||||
VL_RESTORER(m_packageScopep);
|
||||
@@ -129,7 +129,7 @@ class ClassVisitor final : public VNVisitor {
|
||||
void visit(AstNodeModule* nodep) override {
|
||||
// Visit for NodeModules that are not AstClass (AstClass is-a AstNodeModule)
|
||||
// Classes are always under a Package (perhaps $unit) or a module
|
||||
VL_RESTORER(m_prefix);
|
||||
VL_RESTORER_CLEAR(m_prefix);
|
||||
VL_RESTORER(m_modp);
|
||||
m_modp = nodep;
|
||||
m_prefix = nodep->name() + "__03a__03a"; // ::
|
||||
|
||||
Reference in New Issue
Block a user