@@ -16,6 +16,7 @@ Author: Diffblue Ltd.
16
16
17
17
#include < util/arith_tools.h>
18
18
#include < util/format_expr.h>
19
+ #include < util/fresh_symbol.h>
19
20
#include < util/make_unique.h>
20
21
#include < util/string_utils.h>
21
22
@@ -268,11 +269,46 @@ class havoc_generate_function_bodiest : public generate_function_bodiest,
268
269
269
270
if (function.type .return_type () != void_typet ())
270
271
{
272
+ typet type (function.type .return_type ());
273
+ type.remove (ID_C_constant);
274
+
275
+ symbolt &aux_symbol = get_fresh_aux_symbol (
276
+ type,
277
+ id2string (function_name),
278
+ " return_value" ,
279
+ function_symbol.location ,
280
+ ID_C,
281
+ symbol_table);
282
+
283
+ aux_symbol.is_static_lifetime = false ;
284
+
285
+ auto decl_instruction = add_instruction ();
286
+ decl_instruction->make_decl ();
287
+ decl_instruction->code = code_declt (aux_symbol.symbol_expr ());
288
+
289
+ goto_programt dest;
290
+
291
+ havoc_expr_rec (
292
+ aux_symbol.symbol_expr (),
293
+ 0 ,
294
+ function_symbol.location ,
295
+ symbol_table,
296
+ dest);
297
+
298
+ function.body .destructive_append (dest);
299
+
300
+ exprt return_expr = typecast_exprt::conditional_cast (
301
+ aux_symbol.symbol_expr (), function.type .return_type ());
302
+
271
303
auto return_instruction = add_instruction ();
272
304
return_instruction->make_return ();
273
- return_instruction->code = code_returnt (side_effect_expr_nondett (
274
- function.type .return_type (), function_symbol.location ));
305
+ return_instruction->code = code_returnt (return_expr);
306
+
307
+ auto dead_instruction = add_instruction ();
308
+ dead_instruction->make_dead ();
309
+ dead_instruction->code = code_deadt (aux_symbol.symbol_expr ());
275
310
}
311
+
276
312
auto end_function_instruction = add_instruction ();
277
313
end_function_instruction->make_end_function ();
278
314
0 commit comments