@@ -33,7 +33,7 @@ dfcc_libraryt::dfcc_libraryt(
33
33
{
34
34
}
35
35
36
- // / Enum to type name mapping
36
+ // / enum to type name mapping
37
37
static const std::map<dfcc_typet, irep_idt> dfcc_type_name = {
38
38
{dfcc_typet::FREEABLE, CPROVER_PREFIX " freeable_t" },
39
39
{dfcc_typet::ASSIGNABLE, CPROVER_PREFIX " assignable_t" },
@@ -45,7 +45,7 @@ static const std::map<dfcc_typet, irep_idt> dfcc_type_name = {
45
45
{dfcc_typet::SET, CPROVER_PREFIX " assignable_set_t" },
46
46
{dfcc_typet::SET_PTR, CPROVER_PREFIX " assignable_set_ptr_t" }};
47
47
48
- // / Enum to function name mapping
48
+ // / enum to function name mapping
49
49
static const std::map<dfcc_funt, irep_idt> dfcc_fun_name = {
50
50
{dfcc_funt::CAR_CREATE, CPROVER_PREFIX " assignable_car_create" },
51
51
{dfcc_funt::CAR_SET_CREATE, CPROVER_PREFIX " assignable_car_set_create" },
@@ -92,9 +92,17 @@ static const std::map<dfcc_funt, irep_idt> dfcc_fun_name = {
92
92
{dfcc_funt::SET_CHECK_FREES_CLAUSE_INCLUSION,
93
93
CPROVER_PREFIX " assignable_set_check_frees_clause_inclusion" },
94
94
{dfcc_funt::SET_DEALLOCATE_FREEABLE,
95
- CPROVER_PREFIX " assignable_set_deallocate_freeable" }};
96
-
97
- // / Built-in function name to enum to use for instrumentation
95
+ CPROVER_PREFIX " assignable_set_deallocate_freeable" },
96
+ {dfcc_funt::SET_HAVOC_GET_ASSIGNABLE_TARGET,
97
+ CPROVER_PREFIX " assignable_set_havoc_get_assignable_target" },
98
+ {dfcc_funt::SET_HAVOC_WHOLE_OBJECT,
99
+ CPROVER_PREFIX " assignable_set_havoc_whole_object" },
100
+ {dfcc_funt::SET_HAVOC_OBJECT_FROM,
101
+ CPROVER_PREFIX " assignable_set_havoc_object_from" },
102
+ {dfcc_funt::SET_HAVOC_OBJECT_UPTO,
103
+ CPROVER_PREFIX " assignable_set_havoc_object_upto" }};
104
+
105
+ // / built-in function name to enum to use for instrumentation
98
106
static const std::map<irep_idt, dfcc_funt> dfcc_hook = {
99
107
{CPROVER_PREFIX " assignable" , dfcc_funt::SET_INSERT_ASSIGNABLE},
100
108
{CPROVER_PREFIX " whole_object" , dfcc_funt::SET_INSERT_WHOLE_OBJECT},
@@ -111,7 +119,23 @@ optionalt<dfcc_funt> dfcc_libraryt::get_hook(const irep_idt &function_id) const
111
119
return {};
112
120
}
113
121
114
- // / Built-in function names (front-end and instrumentation hooks)
122
+ static const std::map<irep_idt, dfcc_funt> havoc_hook = {
123
+ {CPROVER_PREFIX " assignable" , dfcc_funt::SET_HAVOC_GET_ASSIGNABLE_TARGET},
124
+ {CPROVER_PREFIX " whole_object" , dfcc_funt::SET_HAVOC_WHOLE_OBJECT},
125
+ {CPROVER_PREFIX " object_from" , dfcc_funt::SET_HAVOC_OBJECT_FROM},
126
+ {CPROVER_PREFIX " object_upto" , dfcc_funt::SET_HAVOC_OBJECT_UPTO}};
127
+
128
+ optionalt<dfcc_funt>
129
+ dfcc_libraryt::get_havoc_hook (const irep_idt &function_id) const
130
+ {
131
+ auto found = havoc_hook.find (function_id);
132
+ if (found != havoc_hook.end ())
133
+ return {found->second };
134
+ else
135
+ return {};
136
+ }
137
+
138
+ // / built-in function names (front-end and instrumentation hooks)
115
139
static const std::set<irep_idt> assignable_builtin_names = {
116
140
CPROVER_PREFIX " assignable" ,
117
141
CPROVER_PREFIX " assignable_set_insert_assignable" ,
@@ -144,7 +168,7 @@ void dfcc_libraryt::get_missing_funs(std::set<irep_idt> &missing)
144
168
}
145
169
}
146
170
147
- // true iff library symbols have been loaded
171
+ // true iff library symbols have already been loaded
148
172
static bool loaded = false ;
149
173
150
174
void dfcc_libraryt::load ()
@@ -198,7 +222,6 @@ void dfcc_libraryt::load()
198
222
throw 0 ;
199
223
}
200
224
dfcc_fun_symbol[pair.first ] = ns.lookup (pair.second );
201
- // dfcc_fun_symbol_expr[pair.first] = ns.lookup(pair.second).symbol_expr();
202
225
}
203
226
204
227
// populate symbol maps for easy access to symbols during translation
@@ -221,7 +244,7 @@ bool dfcc_libraryt::is_special_builtin(const irep_idt &id) const
221
244
return special_builtins.find (id) != special_builtins.end ();
222
245
}
223
246
224
- // / Set of functions that need to be inlined for specialisation
247
+ // / set of functions that need to be inlined for specialisation
225
248
static const std::set<dfcc_funt> to_inline = {
226
249
dfcc_funt::SET_CREATE,
227
250
dfcc_funt::SET_INSERT_ASSIGNABLE,
@@ -242,7 +265,9 @@ static const std::set<dfcc_funt> to_inline = {
242
265
dfcc_funt::SET_CHECK_FREES_CLAUSE_INCLUSION,
243
266
dfcc_funt::SET_DEALLOCATE_FREEABLE};
244
267
268
+ // / true iff the library functions have already been inlined
245
269
static bool inlined = false ;
270
+
246
271
void dfcc_libraryt::inline_functions ()
247
272
{
248
273
INVARIANT (!inlined, " inlined_functions can only be called once" );
@@ -253,7 +278,7 @@ void dfcc_libraryt::inline_functions()
253
278
}
254
279
}
255
280
256
- // / Set of functions that need to be unwound to assigns clause size with
281
+ // / set of functions that need to be unwound to assigns clause size with
257
282
// / corresponding loop labels.
258
283
static const std::map<dfcc_funt, irep_idt> to_unwind = {
259
284
{dfcc_funt::SET_REMOVE_DEALLOCATED, " CAR_SET_REMOVE_LOOP" },
@@ -266,7 +291,7 @@ static const std::map<dfcc_funt, irep_idt> to_unwind = {
266
291
// / true iff the library functions have already been specialized
267
292
static bool specialized = false ;
268
293
269
- void dfcc_libraryt::specialize_functions (const int contract_assigns_size_hint)
294
+ void dfcc_libraryt::specialize (const int contract_assigns_size_hint)
270
295
{
271
296
INVARIANT (
272
297
!specialized,
0 commit comments