@@ -13,6 +13,7 @@ Author: Diffblue Ltd.
13
13
14
14
#include < ansi-c/c_object_factory_parameters.h>
15
15
16
+ #include < util/allocate_objects.h>
16
17
#include < util/arith_tools.h>
17
18
#include < util/c_types.h>
18
19
#include < util/fresh_symbol.h>
@@ -47,62 +48,13 @@ class symbol_factoryt
47
48
object_factory_params(object_factory_params)
48
49
{}
49
50
50
- exprt allocate_object (
51
- code_blockt &assignments,
52
- const exprt &target_expr,
53
- const typet &allocate_type,
54
- const bool static_lifetime);
55
-
56
51
void gen_nondet_init (
57
52
code_blockt &assignments,
58
53
const exprt &expr,
59
54
const std::size_t depth = 0 ,
60
55
recursion_sett recursion_set = recursion_sett());
61
56
};
62
57
63
- // / Create a symbol for a pointer to point to
64
- // / \param assignments: The code block to add code to
65
- // / \param target_expr: The expression which we are allocating a symbol for
66
- // / \param allocate_type: The type to use for the symbol. If this doesn't match
67
- // / target_expr then a cast will be used for the assignment
68
- // / \param static_lifetime: Whether the symbol created should have static
69
- // / lifetime
70
- // / \return Returns the address of the allocated symbol
71
- exprt symbol_factoryt::allocate_object (
72
- code_blockt &assignments,
73
- const exprt &target_expr,
74
- const typet &allocate_type,
75
- const bool static_lifetime)
76
- {
77
- symbolt &aux_symbol = get_fresh_aux_symbol (
78
- allocate_type,
79
- id2string (loc.get_function ()),
80
- " tmp" ,
81
- loc,
82
- ID_C,
83
- symbol_table);
84
- aux_symbol.is_static_lifetime = static_lifetime;
85
- symbols_created.push_back (&aux_symbol);
86
-
87
- const typet &allocate_type_resolved=ns.follow (allocate_type);
88
- const typet &target_type=ns.follow (target_expr.type ().subtype ());
89
- bool cast_needed=allocate_type_resolved!=target_type;
90
-
91
- exprt aoe=address_of_exprt (aux_symbol.symbol_expr ());
92
- if (cast_needed)
93
- {
94
- aoe=typecast_exprt (aoe, target_expr.type ());
95
- }
96
-
97
- // Add the following code to assignments:
98
- // <target_expr> = &tmp$<temporary_counter>
99
- code_assignt assign (target_expr, aoe);
100
- assign.add_source_location ()=loc;
101
- assignments.add (std::move (assign));
102
-
103
- return aoe;
104
- }
105
-
106
58
// / Creates a nondet for expr, including calling itself recursively to make
107
59
// / appropriate symbols to point to if expr is a pointer.
108
60
// / \param assignments: The code block to add code to
@@ -142,7 +94,11 @@ void symbol_factoryt::gen_nondet_init(
142
94
143
95
code_blockt non_null_inst;
144
96
145
- exprt allocated=allocate_object (non_null_inst, expr, subtype, false );
97
+ allocate_objectst allocate_objects (
98
+ ID_C, loc, loc.get_function (), symbol_table);
99
+
100
+ exprt allocated = allocate_objects.allocate_non_dynamic_object (
101
+ non_null_inst, expr, subtype, false , symbols_created);
146
102
147
103
exprt init_expr;
148
104
if (allocated.id ()==ID_address_of)
0 commit comments