File tree 6 files changed +36
-0
lines changed
jbmc/regression/jbmc-strings/nondet_propagation 6 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Test {
2
+ public String foo () {
3
+ final int i = 10 ;
4
+ final String retval = Integer .toHexString (i );
5
+ assert (false );
6
+ return retval ;
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ Test.class
3
+ --function Test.foo --trace
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ dynamic_object1=\{ 'a' \}
7
+ --
8
+ --
9
+ Nondet propagation would previously cause an output like
10
+ dynamic_object1=dynamic_object1#2, because the mapping between dynamic_object1#2
11
+ and a nondet-symbol, which was otherwise being used by the string solver, was
12
+ not established.
Original file line number Diff line number Diff line change @@ -67,9 +67,20 @@ literalt arrayst::record_array_equality(
67
67
collect_arrays (op0);
68
68
collect_arrays (op1);
69
69
70
+ lhs_rhs_map.emplace (op0, op1);
71
+
70
72
return array_equalities.back ().l ;
71
73
}
72
74
75
+ exprt arrayst::get (const exprt &expr) const
76
+ {
77
+ auto it = lhs_rhs_map.find (expr);
78
+ if (it != lhs_rhs_map.end () && it->first != it->second )
79
+ return get (it->second );
80
+ else
81
+ return SUB::get (expr);
82
+ }
83
+
73
84
void arrayst::collect_indices ()
74
85
{
75
86
for (std::size_t i=0 ; i<arrays.size (); i++)
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ class arrayst:public equalityt
46
46
literalt record_array_equality (const equal_exprt &expr);
47
47
void record_array_index (const index_exprt &expr);
48
48
49
+ exprt get (const exprt &expr) const override ;
50
+
49
51
protected:
50
52
const namespacet &ns;
51
53
@@ -65,6 +67,7 @@ class arrayst:public equalityt
65
67
// elements are added while references are held
66
68
typedef std::list<array_equalityt> array_equalitiest;
67
69
array_equalitiest array_equalities;
70
+ std::unordered_map<exprt, exprt, irep_hash> lhs_rhs_map;
68
71
69
72
// this is used to find the clusters of arrays being compared
70
73
union_find<exprt> arrays;
Original file line number Diff line number Diff line change @@ -977,6 +977,8 @@ static optionalt<exprt> get_array(
977
977
{
978
978
const exprt &size = arr.length ();
979
979
exprt arr_val = simplify_expr (adjust_if_recursive (super_get (arr), ns), ns);
980
+ if (arr_val.id () == ID_array)
981
+ return std::move (arr_val);
980
982
exprt size_val = super_get (size);
981
983
size_val = simplify_expr (size_val, ns);
982
984
const typet char_type = arr.type ().subtype ();
You can’t perform that action at this time.
0 commit comments