@@ -33,7 +33,7 @@ dfcc_libraryt::dfcc_libraryt(
3333{
3434}
3535
36- // / Enum to type name mapping
36+ // / enum to type name mapping
3737static const std::map<dfcc_typet, irep_idt> dfcc_type_name = {
3838 {dfcc_typet::FREEABLE, CPROVER_PREFIX " freeable_t" },
3939 {dfcc_typet::ASSIGNABLE, CPROVER_PREFIX " assignable_t" },
@@ -45,7 +45,7 @@ static const std::map<dfcc_typet, irep_idt> dfcc_type_name = {
4545 {dfcc_typet::SET, CPROVER_PREFIX " assignable_set_t" },
4646 {dfcc_typet::SET_PTR, CPROVER_PREFIX " assignable_set_ptr_t" }};
4747
48- // / Enum to function name mapping
48+ // / enum to function name mapping
4949static const std::map<dfcc_funt, irep_idt> dfcc_fun_name = {
5050 {dfcc_funt::CAR_CREATE, CPROVER_PREFIX " assignable_car_create" },
5151 {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 = {
9292 {dfcc_funt::SET_CHECK_FREES_CLAUSE_INCLUSION,
9393 CPROVER_PREFIX " assignable_set_check_frees_clause_inclusion" },
9494 {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
98106static const std::map<irep_idt, dfcc_funt> dfcc_hook = {
99107 {CPROVER_PREFIX " assignable" , dfcc_funt::SET_INSERT_ASSIGNABLE},
100108 {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
111119 return {};
112120}
113121
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)
115139static const std::set<irep_idt> assignable_builtin_names = {
116140 CPROVER_PREFIX " assignable" ,
117141 CPROVER_PREFIX " assignable_set_insert_assignable" ,
@@ -144,7 +168,7 @@ void dfcc_libraryt::get_missing_funs(std::set<irep_idt> &missing)
144168 }
145169}
146170
147- // true iff library symbols have been loaded
171+ // true iff library symbols have already been loaded
148172static bool loaded = false ;
149173
150174void dfcc_libraryt::load ()
@@ -198,7 +222,6 @@ void dfcc_libraryt::load()
198222 throw 0 ;
199223 }
200224 dfcc_fun_symbol[pair.first ] = ns.lookup (pair.second );
201- // dfcc_fun_symbol_expr[pair.first] = ns.lookup(pair.second).symbol_expr();
202225 }
203226
204227 // 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
221244 return special_builtins.find (id) != special_builtins.end ();
222245}
223246
224- // / Set of functions that need to be inlined for specialisation
247+ // / set of functions that need to be inlined for specialisation
225248static const std::set<dfcc_funt> to_inline = {
226249 dfcc_funt::SET_CREATE,
227250 dfcc_funt::SET_INSERT_ASSIGNABLE,
@@ -242,7 +265,9 @@ static const std::set<dfcc_funt> to_inline = {
242265 dfcc_funt::SET_CHECK_FREES_CLAUSE_INCLUSION,
243266 dfcc_funt::SET_DEALLOCATE_FREEABLE};
244267
268+ // / true iff the library functions have already been inlined
245269static bool inlined = false ;
270+
246271void dfcc_libraryt::inline_functions ()
247272{
248273 INVARIANT (!inlined, " inlined_functions can only be called once" );
@@ -253,7 +278,7 @@ void dfcc_libraryt::inline_functions()
253278 }
254279}
255280
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
257282// / corresponding loop labels.
258283static const std::map<dfcc_funt, irep_idt> to_unwind = {
259284 {dfcc_funt::SET_REMOVE_DEALLOCATED, " CAR_SET_REMOVE_LOOP" },
@@ -266,7 +291,7 @@ static const std::map<dfcc_funt, irep_idt> to_unwind = {
266291// / true iff the library functions have already been specialized
267292static bool specialized = false ;
268293
269- void dfcc_libraryt::specialize_functions (const int contract_assigns_size_hint)
294+ void dfcc_libraryt::specialize (const int contract_assigns_size_hint)
270295{
271296 INVARIANT (
272297 !specialized,
0 commit comments