@@ -168,7 +168,7 @@ void FstData::extractVarNames()
168168 std::string fst_scope_name;
169169
170170 /* Variables for resolving unions with $fork. */
171- bool detect_union = false ; // if we should be detecting unions with $fork
171+ bool in_fork = false ; // if we are inside a $fork scope
172172 std::string fork_parent_scope; // parent scope of fork (used to resolve union location)
173173 std::string fork_name; // name of fork (used to resolve union name)
174174 std::vector<FstVar> fork_vars; // stores all variables in the fork scope
@@ -177,26 +177,18 @@ void FstData::extractVarNames()
177177 switch (h->htyp ) {
178178 case FST_HT_SCOPE : {
179179 // Handle tracking for potential union structs with $fork.
180- if (!detect_union && h->u .scope .typ == FST_ST_VCD_FORK ) {
181- detect_union = true ;
180+ if (!in_fork && h->u .scope .typ == FST_ST_VCD_FORK ) {
181+ in_fork = true ;
182182 fork_parent_scope = fst_scope_name;
183183 fork_name = h->u .scope .name ;
184184 fork_vars.clear ();
185- } else if (in_fork && h->u .scope .typ == FST_ST_VCD_STRUCT ) {
186- // Signal that a nested $fork can not be a candidate for union struct detection.
187- log_warning (" Nested $fork '%s' inside $fork '%s'; "
188- " abandoning union detection for this scope...\n " ,
189- h->u .scope .name , fork_name.c_str ());
190- for (auto &v : fork_vars) registerVar (v);
191- detect_union = false ;
192- fork_vars.clear ();
193185 }
194186 // Push the scope onto the stack to 'descend' into the hierarchy.
195187 fst_scope_name = fstReaderPushScope (ctx, h->u .scope .name , NULL );
196188 break ;
197189 }
198190 case FST_HT_UPSCOPE : {
199- if (detect_union ) {
191+ if (in_fork ) {
200192 // A union is detected if there are at least 2 variables in the fork scope and they all have the same fstHandle.
201193 bool is_union = fork_vars.size () >= 2 &&
202194 std::all_of (fork_vars.begin () + 1 , fork_vars.end (),
@@ -215,7 +207,7 @@ void FstData::extractVarNames()
215207 registerVar (v);
216208 }
217209 }
218- detect_union = false ;
210+ in_fork = false ;
219211 fork_vars.clear ();
220212 }
221213 // Pop the scope off the stack.
@@ -232,7 +224,7 @@ void FstData::extractVarNames()
232224 normalize_brackets (var.scope );
233225 var.width = h->u .var .length ;
234226
235- if (detect_union ) fork_vars.push_back (var); // store all variables in fork scope into a vector
227+ if (in_fork ) fork_vars.push_back (var); // store all variables in fork scope into a vector
236228 else registerVar (var); // otherwise, register the variable as normal
237229 break ;
238230 }
0 commit comments