@@ -23,7 +23,6 @@ Date: July 2021
2323#include < ansi-c/ansi_c_language.h>
2424#include < linking/static_lifetime_init.h>
2525
26- #include " contracts.h"
2726#include " instrument_spec_assigns.h"
2827#include " utils.h"
2928
@@ -34,6 +33,8 @@ std::set<irep_idt> &functions_in_scope_visitort::function_calls()
3433
3534void functions_in_scope_visitort::operator ()(const goto_programt &prog)
3635{
36+ messaget log{message_handler};
37+
3738 forall_goto_program_instructions (ins, prog)
3839 {
3940 if (ins->is_function_call ())
@@ -163,12 +164,13 @@ void is_fresh_baset::add_memory_map_dead(goto_programt &program)
163164
164165void is_fresh_baset::add_declarations (const std::string &decl_string)
165166{
167+ messaget log{message_handler};
166168 log.debug () << " Creating declarations: \n " << decl_string << " \n " ;
167169
168170 std::istringstream iss (decl_string);
169171
170172 ansi_c_languaget ansi_c_language;
171- ansi_c_language.set_message_handler (log. get_message_handler () );
173+ ansi_c_language.set_message_handler (message_handler );
172174 configt::ansi_ct::preprocessort pp = config.ansi_c .preprocessor ;
173175 config.ansi_c .preprocessor = configt::ansi_ct::preprocessort::NONE;
174176 ansi_c_language.parse (iss, " " );
@@ -181,10 +183,10 @@ void is_fresh_baset::add_declarations(const std::string &decl_string)
181183 goto_functionst tmp_functions;
182184
183185 // Add the new functions into the goto functions table.
184- parent. get_goto_functions () .function_map [ensures_fn_name].copy_from (
186+ goto_model. goto_functions .function_map [ensures_fn_name].copy_from (
185187 tmp_functions.function_map [ensures_fn_name]);
186188
187- parent. get_goto_functions () .function_map [requires_fn_name].copy_from (
189+ goto_model. goto_functions .function_map [requires_fn_name].copy_from (
188190 tmp_functions.function_map [requires_fn_name]);
189191
190192 for (const auto &symbol_pair : tmp_symbol_table.symbols )
@@ -194,31 +196,31 @@ void is_fresh_baset::add_declarations(const std::string &decl_string)
194196 symbol_pair.first == ensures_fn_name ||
195197 symbol_pair.first == requires_fn_name || symbol_pair.first == " malloc" )
196198 {
197- this -> parent . get_symbol_table () .insert (symbol_pair.second );
199+ goto_model. symbol_table .insert (symbol_pair.second );
198200 }
199201 // Parameters are stored as scoped names in the symbol table.
200202 else if (
201203 (has_prefix (
202204 id2string (symbol_pair.first ), id2string (ensures_fn_name) + " ::" ) ||
203205 has_prefix (
204206 id2string (symbol_pair.first ), id2string (requires_fn_name) + " ::" )) &&
205- parent. get_symbol_table () .add (symbol_pair.second ))
207+ goto_model. symbol_table .add (symbol_pair.second ))
206208 {
207209 UNREACHABLE;
208210 }
209211 }
210212
211- if (parent. get_goto_functions () .function_map .erase (INITIALIZE_FUNCTION) != 0 )
213+ if (goto_model. goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
212214 {
213215 static_lifetime_init (
214- parent. get_symbol_table () ,
215- parent. get_symbol_table () .lookup_ref (INITIALIZE_FUNCTION).location );
216+ goto_model. symbol_table ,
217+ goto_model. symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
216218 goto_convert (
217219 INITIALIZE_FUNCTION,
218- parent. get_symbol_table () ,
219- parent. get_goto_functions () ,
220+ goto_model. symbol_table ,
221+ goto_model. goto_functions ,
220222 log.get_message_handler ());
221- parent. get_goto_functions () .update ();
223+ goto_model. goto_functions .update ();
222224 }
223225}
224226
@@ -247,10 +249,10 @@ void is_fresh_baset::update_fn_call(
247249/* Declarations for contract enforcement */
248250
249251is_fresh_enforcet::is_fresh_enforcet (
250- code_contractst &_parent ,
251- messaget _log ,
252- irep_idt _fun_id)
253- : is_fresh_baset(_parent, _log , _fun_id)
252+ goto_modelt &goto_model ,
253+ message_handlert &message_handler ,
254+ const irep_idt & _fun_id)
255+ : is_fresh_baset(goto_model, message_handler , _fun_id)
254256{
255257 std::stringstream ssreq, ssensure, ssmemmap;
256258 ssreq << CPROVER_PREFIX " enforce_requires_is_fresh" ;
@@ -262,20 +264,20 @@ is_fresh_enforcet::is_fresh_enforcet(
262264 ssmemmap << CPROVER_PREFIX " is_fresh_memory_map_" << fun_id;
263265 this ->memmap_name = ssmemmap.str ();
264266
265- const auto &mode = parent. get_symbol_table () .lookup_ref (_fun_id).mode ;
267+ const auto &mode = goto_model. symbol_table .lookup_ref (_fun_id).mode ;
266268 this ->memmap_symbol = new_tmp_symbol (
267269 get_memmap_type (),
268270 source_locationt (),
269271 mode,
270- parent. get_symbol_table () ,
272+ goto_model. symbol_table ,
271273 this ->memmap_name ,
272274 true );
273275}
274276
275277void is_fresh_enforcet::create_declarations ()
276278{
277279 // Check if symbols are already declared
278- if (parent. get_symbol_table (). lookup (requires_fn_name) != nullptr )
280+ if (goto_model. symbol_table . has_symbol (requires_fn_name))
279281 return ;
280282
281283 std::ostringstream oss;
@@ -326,10 +328,10 @@ void is_fresh_enforcet::create_ensures_fn_call(goto_programt::targett &ins)
326328}
327329
328330is_fresh_replacet::is_fresh_replacet (
329- code_contractst &_parent ,
330- messaget _log ,
331- irep_idt _fun_id)
332- : is_fresh_baset(_parent, _log , _fun_id)
331+ goto_modelt &goto_model ,
332+ message_handlert &message_handler ,
333+ const irep_idt & _fun_id)
334+ : is_fresh_baset(goto_model, message_handler , _fun_id)
333335{
334336 std::stringstream ssreq, ssensure, ssmemmap;
335337 ssreq << CPROVER_PREFIX " replace_requires_is_fresh" ;
@@ -341,21 +343,22 @@ is_fresh_replacet::is_fresh_replacet(
341343 ssmemmap << CPROVER_PREFIX " is_fresh_memory_map_" << fun_id;
342344 this ->memmap_name = ssmemmap.str ();
343345
344- const auto &mode = parent. get_symbol_table () .lookup_ref (_fun_id).mode ;
346+ const auto &mode = goto_model. symbol_table .lookup_ref (_fun_id).mode ;
345347 this ->memmap_symbol = new_tmp_symbol (
346348 get_memmap_type (),
347349 source_locationt (),
348350 mode,
349- parent. get_symbol_table () ,
351+ goto_model. symbol_table ,
350352 this ->memmap_name ,
351353 true );
352354}
353355
354356void is_fresh_replacet::create_declarations ()
355357{
356358 // Check if symbols are already declared
357- if (parent. get_symbol_table (). lookup (requires_fn_name) != nullptr )
359+ if (goto_model. symbol_table . has_symbol (requires_fn_name))
358360 return ;
361+
359362 std::ostringstream oss;
360363 std::string cprover_prefix (CPROVER_PREFIX);
361364 oss << " static _Bool " << requires_fn_name
0 commit comments