Skip to content

bits2expr must return an expression of the requested type [blocks: #3652] #3806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/util/simplify_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,12 +1431,10 @@ bool simplify_exprt::simplify_object(exprt &expr)

exprt simplify_exprt::bits2expr(
const std::string &bits,
const typet &_type,
const typet &type,
bool little_endian)
{
// bits start at lowest memory address
const typet &type=ns.follow(_type);

auto type_bits = pointer_offset_bits(type, ns);

if(!type_bits.has_value() || *type_bits != bits.size())
Expand All @@ -1461,15 +1459,16 @@ exprt simplify_exprt::bits2expr(
else if(type.id()==ID_c_enum)
{
exprt val = bits2expr(bits, to_c_enum_type(type).subtype(), little_endian);
val.type()=type;
val.type() = type;
return val;
}
else if(type.id()==ID_c_enum_tag)
return
bits2expr(
bits,
ns.follow_tag(to_c_enum_tag_type(type)),
little_endian);
{
exprt val =
bits2expr(bits, ns.follow_tag(to_c_enum_tag_type(type)), little_endian);
val.type() = type;
return val;
}
else if(type.id()==ID_union)
{
// find a suitable member
Expand All @@ -1486,6 +1485,13 @@ exprt simplify_exprt::bits2expr(
return union_exprt(component.get_name(), val, type);
}
}
else if(type.id() == ID_union_tag)
{
exprt val =
bits2expr(bits, ns.follow_tag(to_union_tag_type(type)), little_endian);
val.type() = type;
return val;
}
else if(type.id()==ID_struct)
{
const struct_typet &struct_type=to_struct_type(type);
Expand Down Expand Up @@ -1516,6 +1522,13 @@ exprt simplify_exprt::bits2expr(

return std::move(result);
}
else if(type.id() == ID_struct_tag)
{
exprt val =
bits2expr(bits, ns.follow_tag(to_struct_tag_type(type)), little_endian);
val.type() = type;
return val;
}
else if(type.id()==ID_array)
{
const array_typet &array_type=to_array_type(type);
Expand Down