@@ -23,7 +23,6 @@ Date: July 2021
23
23
#include < ansi-c/ansi_c_language.h>
24
24
#include < linking/static_lifetime_init.h>
25
25
26
- #include " contracts.h"
27
26
#include " instrument_spec_assigns.h"
28
27
#include " utils.h"
29
28
@@ -34,6 +33,8 @@ std::set<irep_idt> &functions_in_scope_visitort::function_calls()
34
33
35
34
void functions_in_scope_visitort::operator ()(const goto_programt &prog)
36
35
{
36
+ messaget log {message_handler};
37
+
37
38
forall_goto_program_instructions (ins, prog)
38
39
{
39
40
if (ins->is_function_call ())
@@ -163,12 +164,13 @@ void is_fresh_baset::add_memory_map_dead(goto_programt &program)
163
164
164
165
void is_fresh_baset::add_declarations (const std::string &decl_string)
165
166
{
167
+ messaget log {message_handler};
166
168
log .debug () << " Creating declarations: \n " << decl_string << " \n " ;
167
169
168
170
std::istringstream iss (decl_string);
169
171
170
172
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 );
172
174
configt::ansi_ct::preprocessort pp = config.ansi_c .preprocessor ;
173
175
config.ansi_c .preprocessor = configt::ansi_ct::preprocessort::NONE;
174
176
ansi_c_language.parse (iss, " " );
@@ -181,10 +183,10 @@ void is_fresh_baset::add_declarations(const std::string &decl_string)
181
183
goto_functionst tmp_functions;
182
184
183
185
// 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 (
185
187
tmp_functions.function_map [ensures_fn_name]);
186
188
187
- parent. get_goto_functions () .function_map [requires_fn_name].copy_from (
189
+ goto_model. goto_functions .function_map [requires_fn_name].copy_from (
188
190
tmp_functions.function_map [requires_fn_name]);
189
191
190
192
for (const auto &symbol_pair : tmp_symbol_table.symbols )
@@ -194,31 +196,31 @@ void is_fresh_baset::add_declarations(const std::string &decl_string)
194
196
symbol_pair.first == ensures_fn_name ||
195
197
symbol_pair.first == requires_fn_name || symbol_pair.first == " malloc" )
196
198
{
197
- this -> parent . get_symbol_table () .insert (symbol_pair.second );
199
+ goto_model. symbol_table .insert (symbol_pair.second );
198
200
}
199
201
// Parameters are stored as scoped names in the symbol table.
200
202
else if (
201
203
(has_prefix (
202
204
id2string (symbol_pair.first ), id2string (ensures_fn_name) + " ::" ) ||
203
205
has_prefix (
204
206
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 ))
206
208
{
207
209
UNREACHABLE;
208
210
}
209
211
}
210
212
211
- if (parent. get_goto_functions () .function_map .erase (INITIALIZE_FUNCTION) != 0 )
213
+ if (goto_model. goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
212
214
{
213
215
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 );
216
218
goto_convert (
217
219
INITIALIZE_FUNCTION,
218
- parent. get_symbol_table () ,
219
- parent. get_goto_functions () ,
220
+ goto_model. symbol_table ,
221
+ goto_model. goto_functions ,
220
222
log .get_message_handler ());
221
- parent. get_goto_functions () .update ();
223
+ goto_model. goto_functions .update ();
222
224
}
223
225
}
224
226
@@ -247,10 +249,10 @@ void is_fresh_baset::update_fn_call(
247
249
/* Declarations for contract enforcement */
248
250
249
251
is_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)
254
256
{
255
257
std::stringstream ssreq, ssensure, ssmemmap;
256
258
ssreq << CPROVER_PREFIX " enforce_requires_is_fresh" ;
@@ -262,20 +264,20 @@ is_fresh_enforcet::is_fresh_enforcet(
262
264
ssmemmap << CPROVER_PREFIX " is_fresh_memory_map_" << fun_id;
263
265
this ->memmap_name = ssmemmap.str ();
264
266
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 ;
266
268
this ->memmap_symbol = new_tmp_symbol (
267
269
get_memmap_type (),
268
270
source_locationt (),
269
271
mode,
270
- parent. get_symbol_table () ,
272
+ goto_model. symbol_table ,
271
273
this ->memmap_name ,
272
274
true );
273
275
}
274
276
275
277
void is_fresh_enforcet::create_declarations ()
276
278
{
277
279
// 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))
279
281
return ;
280
282
281
283
std::ostringstream oss;
@@ -326,10 +328,10 @@ void is_fresh_enforcet::create_ensures_fn_call(goto_programt::targett &ins)
326
328
}
327
329
328
330
is_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)
333
335
{
334
336
std::stringstream ssreq, ssensure, ssmemmap;
335
337
ssreq << CPROVER_PREFIX " replace_requires_is_fresh" ;
@@ -341,21 +343,22 @@ is_fresh_replacet::is_fresh_replacet(
341
343
ssmemmap << CPROVER_PREFIX " is_fresh_memory_map_" << fun_id;
342
344
this ->memmap_name = ssmemmap.str ();
343
345
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 ;
345
347
this ->memmap_symbol = new_tmp_symbol (
346
348
get_memmap_type (),
347
349
source_locationt (),
348
350
mode,
349
- parent. get_symbol_table () ,
351
+ goto_model. symbol_table ,
350
352
this ->memmap_name ,
351
353
true );
352
354
}
353
355
354
356
void is_fresh_replacet::create_declarations ()
355
357
{
356
358
// 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))
358
360
return ;
361
+
359
362
std::ostringstream oss;
360
363
std::string cprover_prefix (CPROVER_PREFIX);
361
364
oss << " static _Bool " << requires_fn_name
0 commit comments