verilog: rebuild user_type_stack from globals before parsing file
authorXiretza <xiretza@xiretza.xyz>
Tue, 16 Mar 2021 15:42:14 +0000 (16:42 +0100)
committerZachary Snow <zachary.j.snow@gmail.com>
Fri, 19 Mar 2021 00:52:36 +0000 (20:52 -0400)
commit0c66141ed25b0af229551f9ce8fe844be1e88bf3
treef1cf91507dc5fb20ae075f2fd8c28ba7d9d86299
parent3a12617ec0713aeb81fbf4beede804545f762a1f
verilog: rebuild user_type_stack from globals before parsing file

This was actually a ticking UB bomb: after running the parser, the type
maps contain pointers to children of the current AST, which is
recursively deleted after the pass has executed. This leaves the
pointers in user_type_stack dangling, which just happened to never be a
problem due to another bug that causes typedefs from higher-level type
maps to never be considered.

Rebuilding the type stack from the design's globals ensures the AstNode
pointers are valid.
frontends/verilog/verilog_frontend.cc