|
24 | 24 | #include <stack>
|
25 | 25 | #include <ansi-c/string_constant.h>
|
26 | 26 | #include <util/cprover_prefix.h>
|
| 27 | +#include <util/expr_iterator.h> |
27 | 28 | #include <util/replace_expr.h>
|
28 | 29 | #include <util/refined_string_type.h>
|
29 | 30 | #include <util/simplify_expr.h>
|
@@ -1087,6 +1088,32 @@ static exprt negation_of_constraint(const string_constraintt &axiom)
|
1087 | 1088 | return negaxiom;
|
1088 | 1089 | }
|
1089 | 1090 |
|
| 1091 | +/// Result of the solver `supert` should not be interpreted literally for char |
| 1092 | +/// arrays as not all indices are present in the index set. |
| 1093 | +/// In the given expression, we populate arrays at the indices for which the |
| 1094 | +/// solver has no constraint by copying values to the left. |
| 1095 | +/// For example an expression `ARRAY_OF(0) WITH [1:=2] WITH [4:=3]` would |
| 1096 | +/// be interpreted as `{ 2, 2, 3, 3, 3}`. |
| 1097 | +/// \param expr: expression to interpret |
| 1098 | +/// \param string_max_length: maximum size of arrays to consider |
| 1099 | +/// \return the interpreted expression |
| 1100 | +exprt concretize_arrays_in_expression(exprt expr, std::size_t string_max_length) |
| 1101 | +{ |
| 1102 | + auto it=expr.depth_begin(); |
| 1103 | + const auto end=expr.depth_end(); |
| 1104 | + while(it!=end) |
| 1105 | + { |
| 1106 | + if(it->id()==ID_with && it->type().id()==ID_array) |
| 1107 | + { |
| 1108 | + it.mutate()=fill_in_array_with_expr(*it, string_max_length); |
| 1109 | + it.next_sibling_or_parent(); |
| 1110 | + } |
| 1111 | + else |
| 1112 | + ++it; |
| 1113 | + } |
| 1114 | + return expr; |
| 1115 | +} |
| 1116 | + |
1090 | 1117 | /// return true if the current model satisfies all the axioms
|
1091 | 1118 | /// \return a Boolean
|
1092 | 1119 | bool string_refinementt::check_axioms()
|
|
0 commit comments