aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorZachary Snow <zach@zachjs.com>2021-06-17 15:59:59 -0400
committerZachary Snow <zachary.j.snow@gmail.com>2021-07-06 12:15:08 -0400
commit4446cfa524cf06e84add450214f64b2de6e199c3 (patch)
tree629b86e46d14930d22eb40cd2dbef804ac1038c3 /frontends/ast
parent2b8f1633ce7800b4f0315f0206fd0bf9fba5237c (diff)
downloadyosys-4446cfa524cf06e84add450214f64b2de6e199c3.tar.gz
yosys-4446cfa524cf06e84add450214f64b2de6e199c3.tar.bz2
yosys-4446cfa524cf06e84add450214f64b2de6e199c3.zip
sv: fix a few struct and enum memory leaks
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/simplify.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc
index f85306423..695fc429d 100644
--- a/frontends/ast/simplify.cc
+++ b/frontends/ast/simplify.cc
@@ -331,6 +331,8 @@ static int size_packed_struct(AstNode *snode, int base_offset)
}
}
// range nodes are now redundant
+ for (AstNode *child : node->children)
+ delete child;
node->children.clear();
}
else if (node->children.size() == 1 && node->children[0]->type == AST_MULTIRANGE) {
@@ -345,6 +347,8 @@ static int size_packed_struct(AstNode *snode, int base_offset)
save_struct_array_width(node, width);
width *= array_count;
// range nodes are now redundant
+ for (AstNode *child : node->children)
+ delete child;
node->children.clear();
}
else if (node->range_left < 0) {
@@ -5052,6 +5056,9 @@ finished:
void AstNode::allocateDefaultEnumValues()
{
log_assert(type==AST_ENUM);
+ log_assert(children.size() > 0);
+ if (children.front()->attributes.count(ID::enum_base_type))
+ return; // already elaborated
int last_enum_int = -1;
for (auto node : children) {
log_assert(node->type==AST_ENUM_ITEM);