Skip to content

Object descriptor should skip typecasts #33

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 2 commits into from
Jun 6, 2016
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
21 changes: 12 additions & 9 deletions src/util/std_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,15 @@ static void build_object_descriptor_rec(
{
const member_exprt &member=to_member_expr(expr);
const exprt &struct_op=member.struct_op();
const typet &struct_type=ns.follow(struct_op.type());

build_object_descriptor_rec(ns, struct_op, dest);

if(struct_type.id()==ID_union)
return;

mp_integer offset=
member_offset(to_struct_type(struct_type),
member.get_component_name(), ns);
assert(offset>=0);
exprt offset=member_offset_expr(member, ns);
assert(offset.is_not_nil());

dest.offset()=
plus_exprt(dest.offset(), from_integer(offset, index_type));
plus_exprt(dest.offset(),
typecast_exprt(offset, index_type));
}
else if(expr.id()==ID_byte_extract_little_endian ||
expr.id()==ID_byte_extract_big_endian)
Expand All @@ -154,6 +149,14 @@ static void build_object_descriptor_rec(
typecast_exprt(to_byte_extract_expr(expr).offset(),
index_type));
}
else if(expr.id()==ID_typecast)
{
const typecast_exprt &tc=to_typecast_expr(expr);

dest.object()=tc.op();

build_object_descriptor_rec(ns, tc.op(), dest);
}
}

/*******************************************************************\
Expand Down