File tree 3 files changed +36
-2
lines changed 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -207,3 +207,32 @@ optionalt<exprt> string_insertion_builtin_functiont::eval(
207
207
const array_typet type (result.type ().subtype (), length);
208
208
return make_string (result_value, type);
209
209
}
210
+
211
+ string_builtin_function_with_no_evalt::string_builtin_function_with_no_evalt (
212
+ const function_application_exprt &f,
213
+ array_poolt &array_pool)
214
+ : function_application(f)
215
+ {
216
+ const std::vector<exprt> &fun_args = f.arguments ();
217
+ std::size_t i = 0 ;
218
+ if (fun_args.size () >= 2 && fun_args[1 ].type ().id () == ID_pointer)
219
+ {
220
+ string_res = array_pool.find (fun_args[1 ], fun_args[0 ]);
221
+ i = 2 ;
222
+ }
223
+
224
+ for (; i < fun_args.size (); ++i)
225
+ {
226
+ const auto arg = expr_try_dynamic_cast<struct_exprt>(fun_args[i]);
227
+ // TODO: use is_refined_string_type ?
228
+ if (
229
+ arg && arg->operands ().size () == 2 &&
230
+ arg->op1 ().type ().id () == ID_pointer)
231
+ {
232
+ INVARIANT (is_refined_string_type (arg->type ()), " should be a string" );
233
+ string_args.push_back (array_pool.find (arg->op1 (), arg->op0 ()));
234
+ }
235
+ else
236
+ args.push_back (fun_args[i]);
237
+ }
238
+ }
Original file line number Diff line number Diff line change @@ -208,6 +208,11 @@ class string_builtin_function_with_no_evalt : public string_builtin_functiont
208
208
optionalt<array_string_exprt> string_res;
209
209
std::vector<array_string_exprt> string_args;
210
210
std::vector<exprt> args;
211
+
212
+ string_builtin_function_with_no_evalt (
213
+ const function_application_exprt &f,
214
+ array_poolt &array_pool);
215
+
211
216
std::string name () const override
212
217
{
213
218
return id2string (function_application.id ());
Original file line number Diff line number Diff line change @@ -176,8 +176,8 @@ static std::unique_ptr<string_builtin_functiont> to_string_builtin_function(
176
176
: name.get_identifier ();
177
177
178
178
if (id == ID_cprover_string_insert_func)
179
- return std::unique_ptr<string_builtin_functiont >(
180
- new string_insertion_builtin_functiont ( fun_app.arguments (), array_pool) );
179
+ return util_make_unique<string_insertion_builtin_functiont >(
180
+ fun_app.arguments (), array_pool);
181
181
182
182
if (id == ID_cprover_string_concat_func)
183
183
return util_make_unique<string_concatenation_builtin_functiont>(
You can’t perform that action at this time.
0 commit comments