Skip to content

Commit a5092cb

Browse files
authored
Merge pull request #2736 from diffblue/value_set_fi_hacks
tolerate two cases of imprecision in value_set_fi; addresses issue #2653
2 parents 9cead93 + 858532c commit a5092cb

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

src/pointer-analysis/value_set.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,13 +1279,18 @@ void value_sett::assign(
12791279
"rhs.type():\n" +
12801280
rhs.type().pretty() + "\n" + "lhs.type():\n" + lhs.type().pretty());
12811281

1282-
const struct_typet &rhs_struct_type =
1283-
to_struct_type(ns.follow(rhs.type()));
1282+
const typet &followed = ns.follow(rhs.type());
12841283

1285-
const typet &rhs_subtype = rhs_struct_type.component_type(name);
1286-
rhs_member = simplify_expr(member_exprt{rhs, name, rhs_subtype}, ns);
1284+
if(followed.id() == ID_struct || followed.id() == ID_union)
1285+
{
1286+
const struct_union_typet &rhs_struct_union_type =
1287+
to_struct_union_type(followed);
1288+
1289+
const typet &rhs_subtype = rhs_struct_union_type.component_type(name);
1290+
rhs_member = simplify_expr(member_exprt{rhs, name, rhs_subtype}, ns);
12871291

1288-
assign(lhs_member, rhs_member, ns, true, add_to_sets);
1292+
assign(lhs_member, rhs_member, ns, true, add_to_sets);
1293+
}
12891294
}
12901295
}
12911296
}

src/pointer-analysis/value_set_fi.cpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,18 @@ void value_set_fit::get_value_set_rec(
411411
{
412412
const typet &type = to_index_expr(expr).array().type();
413413

414-
DATA_INVARIANT(type.id()==ID_array ||
415-
type.id()=="#REF#",
416-
"operand 0 of index expression must be an array");
417-
418-
get_value_set_rec(
419-
to_index_expr(expr).array(),
420-
dest,
421-
"[]" + suffix,
422-
original_type,
423-
ns,
424-
recursion_set);
414+
if(type.id() == ID_array)
415+
{
416+
get_value_set_rec(
417+
to_index_expr(expr).array(),
418+
dest,
419+
"[]" + suffix,
420+
original_type,
421+
ns,
422+
recursion_set);
423+
}
424+
else
425+
insert(dest, exprt(ID_unknown, original_type));
425426

426427
return;
427428
}
@@ -1192,12 +1193,15 @@ void value_set_fit::assign_rec(
11921193
{
11931194
const typet &type = to_index_expr(lhs).array().type();
11941195

1195-
DATA_INVARIANT(type.id()==ID_array ||
1196-
type.id()=="#REF#",
1197-
"operand 0 of index expression must be an array");
1198-
1199-
assign_rec(
1200-
to_index_expr(lhs).array(), values_rhs, "[]" + suffix, ns, recursion_set);
1196+
if(type.id() == ID_array)
1197+
{
1198+
assign_rec(
1199+
to_index_expr(lhs).array(),
1200+
values_rhs,
1201+
"[]" + suffix,
1202+
ns,
1203+
recursion_set);
1204+
}
12011205
}
12021206
else if(lhs.id()==ID_member)
12031207
{
@@ -1239,9 +1243,9 @@ void value_set_fit::assign_rec(
12391243

12401244
assign_rec(typecast_expr.op(), values_rhs, suffix, ns, recursion_set);
12411245
}
1242-
else if(lhs.id()=="zero_string" ||
1243-
lhs.id()=="is_zero_string" ||
1244-
lhs.id()=="zero_string_length")
1246+
else if(
1247+
lhs.id() == "zero_string" || lhs.id() == "is_zero_string" ||
1248+
lhs.id() == "zero_string_length" || lhs.id() == ID_address_of)
12451249
{
12461250
// ignore
12471251
}

0 commit comments

Comments
 (0)