Skip to content

Commit c1314ae

Browse files
committed
Value-set: replace unsound typecast simplification with simplify_expr
Previously this would simplify ((struct A)x).y into x.y regardless of whether the two structures both have a member y, or whether it is colocated in the two types. Now that the simplifier can soundly simplify such an expression we should just use that instead.
1 parent 71fc87d commit c1314ae

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

src/pointer-analysis/value_set.cpp

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,37 +1630,10 @@ exprt value_sett::make_member(
16301630
const struct_union_typet &struct_union_type=
16311631
to_struct_union_type(ns.follow(src.type()));
16321632

1633-
if(src.id()==ID_struct ||
1634-
src.id()==ID_constant)
1635-
{
1636-
std::size_t no=struct_union_type.component_number(component_name);
1637-
assert(no<src.operands().size());
1638-
return src.operands()[no];
1639-
}
1640-
else if(src.id()==ID_with)
1641-
{
1642-
assert(src.operands().size()==3);
1643-
1644-
// see if op1 is the member we want
1645-
const exprt &member_operand=src.op1();
1646-
1647-
if(component_name==member_operand.get(ID_component_name))
1648-
// yes! just take op2
1649-
return src.op2();
1650-
else
1651-
// no! do this recursively
1652-
return make_member(src.op0(), component_name, ns);
1653-
}
1654-
else if(src.id()==ID_typecast)
1655-
{
1656-
// push through typecast
1657-
assert(src.operands().size()==1);
1658-
return make_member(src.op0(), component_name, ns);
1659-
}
1660-
1661-
// give up
16621633
const typet &subtype = struct_union_type.component_type(component_name);
1663-
member_exprt member_expr(src, component_name, subtype);
1634+
exprt member_expr = member_exprt(src, component_name, subtype);
1635+
1636+
simplify(member_expr, ns);
16641637

1665-
return std::move(member_expr);
1638+
return member_expr;
16661639
}

0 commit comments

Comments
 (0)