@@ -11,22 +11,27 @@ Author: Daniel Kroening, kroening@kroening.com
11
11
12
12
#include " initialize_goto_model.h"
13
13
14
- #include < fstream >
15
-
14
+ #include < util/arith_tools.h >
15
+ # include < util/c_types.h >
16
16
#include < util/config.h>
17
+ #include < util/expr_util.h>
17
18
#include < util/message.h>
18
19
#include < util/options.h>
19
20
21
+ #include < fstream>
22
+
20
23
#ifdef _MSC_VER
21
24
# include < util/unicode.h>
22
25
#endif
23
26
27
+ #include < util/exception_utils.h>
28
+
29
+ #include < goto-programs/rebuild_goto_start_function.h>
30
+
24
31
#include < langapi/language.h>
25
32
#include < langapi/language_file.h>
26
33
#include < langapi/mode.h>
27
-
28
- #include < goto-programs/rebuild_goto_start_function.h>
29
- #include < util/exception_utils.h>
34
+ #include < linking/static_lifetime_init.h>
30
35
31
36
#include " goto_convert_functions.h"
32
37
#include " read_goto_binary.h"
@@ -245,3 +250,64 @@ goto_modelt initialize_goto_model(
245
250
246
251
return goto_model;
247
252
}
253
+
254
+ void update_max_malloc_size (
255
+ goto_modelt &goto_model,
256
+ message_handlert &message_handler)
257
+ {
258
+ if (!goto_model.symbol_table .has_symbol (CPROVER_PREFIX " max_malloc_size" ))
259
+ return ;
260
+
261
+ const auto previous_max_malloc_size_value = numeric_cast<mp_integer>(
262
+ goto_model.symbol_table .lookup_ref (CPROVER_PREFIX " max_malloc_size" ).value );
263
+ const mp_integer current_max_malloc_size = config.max_malloc_size ();
264
+
265
+ if (
266
+ !previous_max_malloc_size_value.has_value () ||
267
+ *previous_max_malloc_size_value != current_max_malloc_size)
268
+ {
269
+ symbolt &max_malloc_size_sym = goto_model.symbol_table .get_writeable_ref (
270
+ CPROVER_PREFIX " max_malloc_size" );
271
+ max_malloc_size_sym.value =
272
+ from_integer (current_max_malloc_size, size_type ());
273
+
274
+ if (goto_model.can_produce_function (INITIALIZE_FUNCTION))
275
+ recreate_initialize_function (goto_model, message_handler);
276
+ }
277
+ }
278
+
279
+ void update_malloc_configuration (
280
+ goto_modelt &goto_model,
281
+ message_handlert &message_handler)
282
+ {
283
+ const symbolt *malloc_may_fail_ptr =
284
+ goto_model.symbol_table .lookup (CPROVER_PREFIX " malloc_may_fail" );
285
+ if (!malloc_may_fail_ptr)
286
+ return ;
287
+
288
+ bool reinit_required = false ;
289
+ if (malloc_may_fail_ptr->value .is_true () != config.ansi_c .malloc_may_fail )
290
+ {
291
+ symbolt &malloc_may_fail_sym = goto_model.symbol_table .get_writeable_ref (
292
+ CPROVER_PREFIX " malloc_may_fail" );
293
+ malloc_may_fail_sym.value =
294
+ make_boolean_expr (config.ansi_c .malloc_may_fail );
295
+ reinit_required = true ;
296
+ }
297
+
298
+ symbolt &malloc_failure_mode_sym = goto_model.symbol_table .get_writeable_ref (
299
+ CPROVER_PREFIX " malloc_failure_mode" );
300
+ const auto previous_failure_mode =
301
+ numeric_cast<mp_integer>(malloc_failure_mode_sym.value );
302
+ if (
303
+ !previous_failure_mode.has_value () ||
304
+ *previous_failure_mode != config.ansi_c .malloc_failure_mode )
305
+ {
306
+ malloc_failure_mode_sym.value =
307
+ from_integer (config.ansi_c .malloc_failure_mode , signed_int_type ());
308
+ reinit_required = true ;
309
+ }
310
+
311
+ if (reinit_required && goto_model.can_produce_function (INITIALIZE_FUNCTION))
312
+ recreate_initialize_function (goto_model, message_handler);
313
+ }
0 commit comments