File tree 10 files changed +36
-87
lines changed
10 files changed +36
-87
lines changed Original file line number Diff line number Diff line change @@ -84,21 +84,8 @@ int linker_script_merget::add_linker_script_definitions()
84
84
<< messaget::eom;
85
85
return fail;
86
86
}
87
- if (
88
- original_goto_model->goto_functions .function_map .erase (
89
- INITIALIZE_FUNCTION) != 0 )
90
- {
91
- static_lifetime_init (
92
- original_goto_model->symbol_table ,
93
- original_goto_model->symbol_table .lookup_ref (INITIALIZE_FUNCTION)
94
- .location );
95
- goto_convert (
96
- INITIALIZE_FUNCTION,
97
- original_goto_model->symbol_table ,
98
- original_goto_model->goto_functions ,
99
- log .get_message_handler ());
100
- original_goto_model->goto_functions .update ();
101
- }
87
+
88
+ recreate_initialize_function (*original_goto_model, log .get_message_handler ());
102
89
103
90
fail=goto_and_object_mismatch (linker_defined_symbols, linker_values);
104
91
if (fail!=0 )
Original file line number Diff line number Diff line change @@ -539,8 +539,7 @@ void dfcct::reinitialize_model()
539
539
swap_and_wrap.get_swapped_functions (instrumented_functions);
540
540
541
541
log .status () << " Updating init function" << messaget::eom;
542
- utils.create_initialize_function ();
543
- goto_model.goto_functions .update ();
542
+ recreate_initialize_function (goto_model, message_handler);
544
543
nondet_static (goto_model, to_exclude_from_nondet_static);
545
544
546
545
// Initialize the map of instrumented functions by adding extra instructions
Original file line number Diff line number Diff line change @@ -140,22 +140,6 @@ const symbolt &dfcc_utilst::create_static_symbol(
140
140
return symbol;
141
141
}
142
142
143
- void dfcc_utilst::create_initialize_function ()
144
- {
145
- if (goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
146
- {
147
- static_lifetime_init (
148
- goto_model.symbol_table ,
149
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
150
- goto_convert (
151
- INITIALIZE_FUNCTION,
152
- goto_model.symbol_table ,
153
- goto_model.goto_functions ,
154
- message_handler);
155
- goto_model.goto_functions .update ();
156
- }
157
- }
158
-
159
143
void dfcc_utilst::fix_parameters_symbols (const irep_idt &function_id)
160
144
{
161
145
auto &function_symbol = get_function_symbol (function_id);
Original file line number Diff line number Diff line change @@ -82,10 +82,6 @@ class dfcc_utilst
82
82
const exprt &initial_value,
83
83
const bool no_nondet_initialization = true );
84
84
85
- // / Regenerates the CPROVER_INITIALIZE function which defines all global
86
- // / statics of the goto model.
87
- void create_initialize_function ();
88
-
89
85
// / Creates a new parameter symbol for the given function_id
90
86
const symbolt &create_new_parameter_symbol (
91
87
const irep_idt &function_id,
Original file line number Diff line number Diff line change @@ -210,18 +210,7 @@ void is_fresh_baset::add_declarations(const std::string &decl_string)
210
210
}
211
211
}
212
212
213
- if (goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
214
- {
215
- static_lifetime_init (
216
- goto_model.symbol_table ,
217
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
218
- goto_convert (
219
- INITIALIZE_FUNCTION,
220
- goto_model.symbol_table ,
221
- goto_model.goto_functions ,
222
- log .get_message_handler ());
223
- goto_model.goto_functions .update ();
224
- }
213
+ recreate_initialize_function (goto_model, message_handler);
225
214
}
226
215
227
216
void is_fresh_baset::update_fn_call (
Original file line number Diff line number Diff line change @@ -40,18 +40,7 @@ static symbol_exprt add_stack_depth_symbol(
40
40
bool failed = goto_model.symbol_table .add (new_symbol);
41
41
CHECK_RETURN (!failed);
42
42
43
- if (goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
44
- {
45
- static_lifetime_init (
46
- goto_model.symbol_table ,
47
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
48
- goto_convert (
49
- INITIALIZE_FUNCTION,
50
- goto_model.symbol_table ,
51
- goto_model.goto_functions ,
52
- message_handler);
53
- goto_model.goto_functions .update ();
54
- }
43
+ recreate_initialize_function (goto_model, message_handler);
55
44
56
45
return new_symbol.symbol_expr ();
57
46
}
Original file line number Diff line number Diff line change @@ -160,18 +160,7 @@ void link_to_library(
160
160
}
161
161
162
162
if (need_reinit)
163
- {
164
- goto_model.unload (INITIALIZE_FUNCTION);
165
- static_lifetime_init (
166
- goto_model.symbol_table ,
167
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
168
- goto_convert (
169
- INITIALIZE_FUNCTION,
170
- goto_model.symbol_table ,
171
- goto_model.goto_functions ,
172
- message_handler);
173
- goto_model.goto_functions .update ();
174
- }
163
+ recreate_initialize_function (goto_model, message_handler);
175
164
176
165
if (!object_type_updates.empty ())
177
166
finalize_linking (goto_model, object_type_updates);
Original file line number Diff line number Diff line change @@ -132,18 +132,6 @@ void slice_global_inits(
132
132
}
133
133
}
134
134
135
- if (
136
- changed &&
137
- goto_model.goto_functions .function_map .erase (INITIALIZE_FUNCTION) != 0 )
138
- {
139
- static_lifetime_init (
140
- goto_model.symbol_table ,
141
- goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
142
- goto_convert (
143
- INITIALIZE_FUNCTION,
144
- goto_model.symbol_table ,
145
- goto_model.goto_functions ,
146
- message_handler);
147
- goto_model.goto_functions .update ();
148
- }
135
+ if (changed)
136
+ recreate_initialize_function (goto_model, message_handler);
149
137
}
Original file line number Diff line number Diff line change 16
16
#include < util/std_code.h>
17
17
#include < util/symbol_table_base.h>
18
18
19
+ #include < goto-programs/goto_convert_functions.h>
20
+ #include < goto-programs/goto_model.h>
21
+
19
22
#include < set>
20
23
21
24
static optionalt<codet> static_lifetime_init (
@@ -157,3 +160,21 @@ void static_lifetime_init(
157
160
}
158
161
}
159
162
}
163
+
164
+ void recreate_initialize_function (
165
+ goto_modelt &goto_model,
166
+ message_handlert &message_handler)
167
+ {
168
+ if (goto_model.unload (INITIALIZE_FUNCTION) != 0 )
169
+ {
170
+ static_lifetime_init (
171
+ goto_model.symbol_table ,
172
+ goto_model.symbol_table .lookup_ref (INITIALIZE_FUNCTION).location );
173
+ goto_convert (
174
+ INITIALIZE_FUNCTION,
175
+ goto_model.symbol_table ,
176
+ goto_model.goto_functions ,
177
+ message_handler);
178
+ goto_model.goto_functions .update ();
179
+ }
180
+ }
Original file line number Diff line number Diff line change 12
12
13
13
#include < util/cprover_prefix.h>
14
14
15
+ class goto_modelt ;
16
+ class message_handlert ;
15
17
class source_locationt ;
16
18
class symbol_table_baset ;
17
19
@@ -21,4 +23,9 @@ void static_lifetime_init(
21
23
22
24
#define INITIALIZE_FUNCTION CPROVER_PREFIX " initialize"
23
25
26
+ // / Regenerates the CPROVER_INITIALIZE function, which initializes all
27
+ // / non-function symbols of the goto model that have static lifetime. This is a
28
+ // / no-op if CPROVER_INITIALIZE was not present beforehand.
29
+ void recreate_initialize_function (goto_modelt &, message_handlert &);
30
+
24
31
#endif // CPROVER_LINKING_STATIC_LIFETIME_INIT_H
You can’t perform that action at this time.
0 commit comments