@@ -55,9 +55,12 @@ exprt sum_overflows(const plus_exprt &sum)
55
55
// / Insert in `array_pool` a binding from `ptr` to `arr`. If the length of `arr`
56
56
// / is infinite, a new integer symbol is created and stored in `array_pool`.
57
57
// / This also adds the default axioms for `arr`.
58
+ // / \param return_code: expression which is assigned the result of the function
58
59
// / \param f: a function application with argument a character array `arr` and
59
60
// / a character pointer `ptr`.
61
+ // / \return a constraint
60
62
exprt string_constraint_generatort::associate_array_to_pointer (
63
+ const exprt &return_code,
61
64
const function_application_exprt &f)
62
65
{
63
66
PRECONDITION (f.arguments ().size () == 2 );
@@ -71,31 +74,26 @@ exprt string_constraint_generatort::associate_array_to_pointer(
71
74
const exprt &pointer_expr = f.arguments ()[1 ];
72
75
array_pool.insert (simplify_expr (pointer_expr, ns), array_expr);
73
76
// created_strings.emplace(to_array_string_expr(array_expr));
74
- return from_integer (0 , f.type ());
77
+ return equal_exprt{return_code, from_integer (0 , f.type ())} ;
75
78
}
76
79
77
80
// / Associate an integer length to a char array.
78
81
// / This adds an axiom ensuring that `arr.length` and `length` are equal.
82
+ // / \param return_code: expression which is assigned the result of the function
79
83
// / \param f: a function application with argument a character array `arr` and
80
84
// / an integer `length`.
81
- // / \return integer expression equal to 0
85
+ // / \return a constraint
82
86
exprt string_constraint_generatort::associate_length_to_array (
87
+ const exprt &return_code,
83
88
const function_application_exprt &f)
84
89
{
85
90
PRECONDITION (f.arguments ().size () == 2 );
86
91
array_string_exprt array_expr = to_array_string_expr (f.arguments ()[0 ]);
87
92
const exprt &new_length = f.arguments ()[1 ];
88
93
89
94
const auto &length = array_pool.get_or_create_length (array_expr);
90
- constraints.existential .push_back (equal_exprt (length, new_length));
91
- return from_integer (0 , f.type ());
92
- }
93
-
94
- void string_constraintst::clear ()
95
- {
96
- existential.clear ();
97
- universal.clear ();
98
- not_contains.clear ();
95
+ return and_exprt{equal_exprt{return_code, from_integer (0 , f.type ())},
96
+ equal_exprt (length, new_length)};
99
97
}
100
98
101
99
// / Merge two sets of constraints by appending to the first one
@@ -200,13 +198,14 @@ static irep_idt get_function_name(const function_application_exprt &expr)
200
198
}
201
199
202
200
optionalt<exprt> string_constraint_generatort::make_array_pointer_association (
201
+ const exprt &return_code,
203
202
const function_application_exprt &expr)
204
203
{
205
204
const irep_idt &id = get_function_name (expr);
206
205
if (id == ID_cprover_associate_array_to_pointer_func)
207
- return associate_array_to_pointer (expr);
206
+ return associate_array_to_pointer (return_code, expr);
208
207
else if (id == ID_cprover_associate_length_to_array_func)
209
- return associate_length_to_array (expr);
208
+ return associate_length_to_array (return_code, expr);
210
209
return {};
211
210
}
212
211
0 commit comments