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 @@ -68,9 +68,20 @@ literalt arrayst::record_array_equality(
68
68
collect_arrays (op0);
69
69
collect_arrays (op1);
70
70
71
+ lhs_rhs_map.emplace (op0, op1);
72
+
71
73
return array_equalities.back ().l ;
72
74
}
73
75
76
+ exprt arrayst::get (const exprt &expr) const
77
+ {
78
+ auto it = lhs_rhs_map.find (expr);
79
+ if (it != lhs_rhs_map.end () && it->first != it->second )
80
+ return get (it->second );
81
+ else
82
+ return SUB::get (expr);
83
+ }
84
+
74
85
void arrayst::collect_indices ()
75
86
{
76
87
for (std::size_t i=0 ; i<arrays.size (); i++)
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ class arrayst:public equalityt
43
43
literalt record_array_equality (const equal_exprt &expr);
44
44
void record_array_index (const index_exprt &expr);
45
45
46
+ exprt get (const exprt &expr) const override ;
47
+
46
48
protected:
47
49
const namespacet &ns;
48
50
@@ -62,6 +64,7 @@ class arrayst:public equalityt
62
64
// elements are added while references are held
63
65
typedef std::list<array_equalityt> array_equalitiest;
64
66
array_equalitiest array_equalities;
67
+ std::unordered_map<exprt, exprt, irep_hash> lhs_rhs_map;
65
68
66
69
// this is used to find the clusters of arrays being compared
67
70
union_find<exprt> arrays;
Original file line number Diff line number Diff line change @@ -964,6 +964,8 @@ static optionalt<exprt> get_array(
964
964
const auto eom = messaget::eom;
965
965
const exprt &size = arr.length ();
966
966
exprt arr_val = simplify_expr (adjust_if_recursive (super_get (arr), ns), ns);
967
+ if (arr_val.id () == ID_array)
968
+ return std::move (arr_val);
967
969
exprt size_val = super_get (size);
968
970
size_val = simplify_expr (size_val, ns);
969
971
const typet char_type = arr.type ().subtype ();
You can’t perform that action at this time.
0 commit comments