Skip to content

Commit 02b7942

Browse files
Simplifying expressions of the form &array[0] in json
We simplifying these expression so that these pointers appear correctly in the trace in json. This is related to issue diffblue/test-gen#21 Includes improvements in json_expr.cpp following review of PR#922
1 parent a9de859 commit 02b7942

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/util/json_expr.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,26 @@ static exprt simplify_json_expr(
5252
id2string(to_member_expr(
5353
src.op0()).get_component_name()).find("@")!=std::string::npos)
5454
{
55-
// simplify things of the form &member_expr(object, @class_identifier)
55+
// simplify expressions of the form &member_expr(object, @class_identifier)
5656
return simplify_json_expr(src.op0(), ns);
5757
}
58+
else if(src.id()==ID_address_of &&
59+
src.operands().size()==1 &&
60+
src.op0().id()==ID_index &&
61+
to_index_expr(src.op0()).index().id()==ID_constant &&
62+
to_constant_expr(
63+
to_index_expr(src.op0()).index()).value_is_zero_string())
64+
{
65+
// simplify expressions of the form &array[0]
66+
return simplify_json_expr(to_index_expr(src.op0()).array(), ns);
67+
}
5868
else if(src.id()==ID_member &&
5969
src.operands().size()==1 &&
6070
id2string(
6171
to_member_expr(src).get_component_name())
6272
.find("@")!=std::string::npos)
6373
{
64-
// simplify things of the form member_expr(object, @class_identifier)
74+
// simplify expressions of the form member_expr(object, @class_identifier)
6575
return simplify_json_expr(src.op0(), ns);
6676
}
6777

0 commit comments

Comments
 (0)