Skip to content

Value sets: handle extractbits out of pointers #7339

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
Nov 19, 2022
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
38 changes: 35 additions & 3 deletions src/pointer-analysis/value_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected]
#include "value_set.h"

#include <util/arith_tools.h>
#include <util/bitvector_expr.h>
#include <util/byte_operators.h>
#include <util/c_types.h>
#include <util/expr_util.h>
Expand Down Expand Up @@ -589,8 +590,9 @@ void value_sett::get_value_set_rec(
// pointer-to-pointer -- we just ignore these
get_value_set_rec(op, dest, suffix, original_type, ns);
}
else if(op_type.id()==ID_unsignedbv ||
op_type.id()==ID_signedbv)
else if(
op_type.id() == ID_unsignedbv || op_type.id() == ID_signedbv ||
op_type.id() == ID_bv)
{
// integer-to-pointer

Expand Down Expand Up @@ -1052,9 +1054,39 @@ void value_sett::get_value_set_rec(
value_set_with_local_definition.get_value_set_rec(
let_expr.where(), dest, suffix, original_type, ns);
}
else if(auto eb = expr_try_dynamic_cast<extractbits_exprt>(expr))
{
object_mapt pointer_expr_set;
get_value_set_rec(eb->src(), pointer_expr_set, "", eb->src().type(), ns);

for(const auto &object_map_entry : pointer_expr_set.read())
{
offsett offset = object_map_entry.second;

// kill any offset
offset.reset();

insert(dest, object_map_entry.first, offset);
}
}
else
{
insert(dest, exprt(ID_unknown, original_type));
object_mapt pointer_expr_set;
for(const auto &op : expr.operands())
get_value_set_rec(op, pointer_expr_set, "", original_type, ns);

for(const auto &object_map_entry : pointer_expr_set.read())
{
offsett offset = object_map_entry.second;

// kill any offset
offset.reset();

insert(dest, object_map_entry.first, offset);
}

if(pointer_expr_set.read().empty())
insert(dest, exprt(ID_unknown, original_type));
}

#ifdef DEBUG
Expand Down