23
23
#include < linking/static_lifetime_init.h>
24
24
#include " abstraction.h"
25
25
26
- void expr_type_relation::link (size_t i1, size_t i2)
26
+ void am_abstractiont:: expr_type_relation::link (size_t i1, size_t i2)
27
27
{
28
28
edges[i1].push_back (i2);
29
29
edges[i2].push_back (i1);
30
30
}
31
31
32
- void expr_type_relation::link_array (size_t i1, size_t i2)
32
+ void am_abstractiont:: expr_type_relation::link_array (size_t i1, size_t i2)
33
33
{
34
34
edges_array[i1].push_back (i2);
35
35
edges_array[i2].push_back (i1);
36
36
}
37
37
38
- size_t expr_type_relation::add_expr (const exprt &expr)
38
+ size_t am_abstractiont:: expr_type_relation::add_expr (const exprt &expr)
39
39
{
40
40
size_t index = expr_list.size ();
41
41
expr_list.push_back (expr);
@@ -110,7 +110,7 @@ size_t expr_type_relation::add_expr(const exprt &expr)
110
110
return index ;
111
111
}
112
112
113
- void expr_type_relation::solve ()
113
+ void am_abstractiont:: expr_type_relation::solve ()
114
114
{
115
115
while (!todo.empty ())
116
116
{
@@ -141,7 +141,7 @@ void expr_type_relation::solve()
141
141
}
142
142
}
143
143
144
- void expr_type_relation::solve_array ()
144
+ void am_abstractiont:: expr_type_relation::solve_array ()
145
145
{
146
146
while (!todo_array.empty ())
147
147
{
@@ -172,15 +172,15 @@ void expr_type_relation::solve_array()
172
172
}
173
173
}
174
174
175
- void link_abst_functions (goto_modelt &goto_model, const abstraction_spect &abst_spec, ui_message_handlert &msg_handler, const optionst &options)
175
+ void am_abstractiont:: link_abst_functions (goto_modelt &goto_model, const abstraction_spect &abst_spec, ui_message_handlert &msg_handler, const optionst &options)
176
176
{
177
177
std::vector<std::string> abstfiles = abst_spec.get_abstraction_function_files (); // get abst function file names
178
178
goto_modelt goto_model_for_abst_fns = initialize_goto_model (abstfiles, msg_handler, options); // read files
179
179
link_goto_model (goto_model, goto_model_for_abst_fns, msg_handler); // link goto model
180
180
}
181
181
182
182
const std::tuple<std::unordered_set<irep_idt>, std::unordered_set<irep_idt>>
183
- find_index_symbols (
183
+ am_abstractiont:: find_index_symbols (
184
184
const goto_functiont &goto_function,
185
185
const irep_idt &array_name)
186
186
{
@@ -286,7 +286,7 @@ find_index_symbols(
286
286
return result;
287
287
}
288
288
289
- void complete_abst_spec (const goto_functiont& goto_function, abstraction_spect &abst_spec)
289
+ void am_abstractiont:: complete_abst_spec (const goto_functiont& goto_function, abstraction_spect &abst_spec)
290
290
{
291
291
for (auto &spec: abst_spec.get_specs ())
292
292
{
@@ -327,7 +327,7 @@ irep_idt check_expr_is_symbol(const exprt &expr)
327
327
328
328
// go into a function to find all function calls we'll need to abstract
329
329
std::vector<std::tuple<irep_idt, std::unordered_map<irep_idt, irep_idt>>>
330
- find_function_calls (irep_idt func_name, goto_modelt &goto_model, const abstraction_spect &abst_spec)
330
+ am_abstractiont:: find_function_calls (irep_idt func_name, goto_modelt &goto_model, const abstraction_spect &abst_spec)
331
331
{
332
332
std::vector<std::tuple<irep_idt, std::unordered_map<irep_idt, irep_idt>>> result;
333
333
@@ -359,7 +359,7 @@ find_function_calls(irep_idt func_name, goto_modelt &goto_model, const abstracti
359
359
}
360
360
361
361
std::unordered_map<irep_idt, abstraction_spect>
362
- calculate_complete_abst_specs_for_funcs (goto_modelt &goto_model, abstraction_spect &abst_spec)
362
+ am_abstractiont:: calculate_complete_abst_specs_for_funcs (goto_modelt &goto_model, abstraction_spect &abst_spec)
363
363
{
364
364
std::unordered_map<irep_idt, abstraction_spect> function_spec_map; // map from function to its abst_spec
365
365
const goto_functiont &init_function = goto_model.get_goto_function (abst_spec.get_func_name ());
@@ -423,7 +423,7 @@ calculate_complete_abst_specs_for_funcs(goto_modelt &goto_model, abstraction_spe
423
423
return function_spec_map;
424
424
}
425
425
426
- bool contains_an_entity_to_be_abstracted (const exprt &expr, const abstraction_spect &abst_spec)
426
+ bool am_abstractiont:: contains_an_entity_to_be_abstracted (const exprt &expr, const abstraction_spect &abst_spec)
427
427
{
428
428
struct match_abst_symbolt
429
429
{
@@ -444,12 +444,12 @@ bool contains_an_entity_to_be_abstracted(const exprt &expr, const abstraction_sp
444
444
445
445
}
446
446
447
- irep_idt get_abstract_name (const irep_idt &old_name)
447
+ irep_idt am_abstractiont:: get_abstract_name (const irep_idt &old_name)
448
448
{
449
449
return irep_idt (std::string (old_name.c_str ())+" $abst" );
450
450
}
451
451
452
- bool contains_a_function_call (const exprt &expr)
452
+ bool am_abstractiont:: contains_a_function_call (const exprt &expr)
453
453
{
454
454
class find_functiont : public const_expr_visitort
455
455
{
@@ -473,7 +473,7 @@ bool contains_a_function_call(const exprt &expr)
473
473
return ff.found ;
474
474
}
475
475
476
- std::vector<exprt> get_direct_access_exprs (const exprt &expr, const abstraction_spect::spect &spec)
476
+ std::vector<exprt> am_abstractiont:: get_direct_access_exprs (const exprt &expr, const abstraction_spect::spect &spec)
477
477
{
478
478
class find_direct_accesst : public const_expr_visitort
479
479
{
@@ -518,7 +518,7 @@ std::vector<exprt> get_direct_access_exprs(const exprt &expr, const abstraction_
518
518
return result;
519
519
}
520
520
521
- exprt add_guard_expression_to_assert (
521
+ exprt am_abstractiont:: add_guard_expression_to_assert (
522
522
const exprt &expr,
523
523
const exprt &expr_before_abst,
524
524
const abstraction_spect &abst_spec,
@@ -581,7 +581,7 @@ exprt add_guard_expression_to_assert(
581
581
}
582
582
}
583
583
584
- void declare_abst_variables_for_func (
584
+ void am_abstractiont:: declare_abst_variables_for_func (
585
585
goto_modelt &goto_model,
586
586
const irep_idt &func_name,
587
587
const abstraction_spect &abst_spec,
@@ -676,7 +676,7 @@ void declare_abst_variables_for_func(
676
676
}
677
677
}
678
678
679
- bool check_if_exprt_eval_to_abst_index (
679
+ bool am_abstractiont:: check_if_exprt_eval_to_abst_index (
680
680
const exprt &expr,
681
681
const abstraction_spect &abst_spec,
682
682
abstraction_spect::spect &spec)
@@ -763,7 +763,7 @@ bool check_if_exprt_eval_to_abst_index(
763
763
}
764
764
}
765
765
766
- symbolt create_function_call (
766
+ symbolt am_abstractiont:: create_function_call (
767
767
const irep_idt &func_name,
768
768
const exprt::operandst operands,
769
769
const irep_idt &caller,
@@ -830,7 +830,7 @@ symbolt create_function_call(
830
830
return new_symb;
831
831
}
832
832
833
- exprt abstract_expr_write (
833
+ exprt am_abstractiont:: abstract_expr_write (
834
834
const exprt &expr,
835
835
const abstraction_spect &abst_spec,
836
836
const goto_modelt &goto_model,
@@ -871,7 +871,7 @@ exprt abstract_expr_write(
871
871
}
872
872
}
873
873
874
- exprt create_comparator_expr_abs_abs (
874
+ exprt am_abstractiont:: create_comparator_expr_abs_abs (
875
875
const exprt &orig_expr,
876
876
const abstraction_spect::spect &spec,
877
877
const goto_modelt &goto_model,
@@ -906,7 +906,7 @@ exprt create_comparator_expr_abs_abs(
906
906
return std::move (result_expr);
907
907
}
908
908
909
- exprt abstract_expr_read_comparator (
909
+ exprt am_abstractiont:: abstract_expr_read_comparator (
910
910
const exprt &expr,
911
911
const abstraction_spect &abst_spec,
912
912
const goto_modelt &goto_model,
@@ -1022,7 +1022,7 @@ exprt abstract_expr_read_comparator(
1022
1022
}
1023
1023
1024
1024
// check whether an expr is a pointer offset
1025
- bool is_pointer_offset (const exprt &expr)
1025
+ bool am_abstractiont:: is_pointer_offset (const exprt &expr)
1026
1026
{
1027
1027
if (expr.id () == ID_pointer_offset)
1028
1028
{
@@ -1039,7 +1039,7 @@ bool is_pointer_offset(const exprt &expr)
1039
1039
}
1040
1040
}
1041
1041
1042
- exprt abstract_expr_read_plusminus (
1042
+ exprt am_abstractiont:: abstract_expr_read_plusminus (
1043
1043
const exprt &expr,
1044
1044
const abstraction_spect &abst_spec,
1045
1045
const goto_modelt &goto_model,
@@ -1111,7 +1111,7 @@ exprt abstract_expr_read_plusminus(
1111
1111
}
1112
1112
}
1113
1113
1114
- exprt abstract_expr_read_dereference (
1114
+ exprt am_abstractiont:: abstract_expr_read_dereference (
1115
1115
const exprt &expr,
1116
1116
const abstraction_spect &abst_spec,
1117
1117
const goto_modelt &goto_model,
@@ -1215,7 +1215,7 @@ exprt abstract_expr_read_dereference(
1215
1215
}
1216
1216
}
1217
1217
1218
- exprt abstract_expr_read (
1218
+ exprt am_abstractiont:: abstract_expr_read (
1219
1219
const exprt &expr,
1220
1220
const abstraction_spect &abst_spec,
1221
1221
const goto_modelt &goto_model,
@@ -1293,7 +1293,7 @@ exprt abstract_expr_read(
1293
1293
}
1294
1294
}
1295
1295
1296
- void define_concrete_indices (goto_modelt &goto_model, const abstraction_spect &abst_spec)
1296
+ void am_abstractiont:: define_concrete_indices (goto_modelt &goto_model, const abstraction_spect &abst_spec)
1297
1297
{
1298
1298
for (const auto &spec: abst_spec.get_specs ())
1299
1299
{
@@ -1333,10 +1333,8 @@ void define_concrete_indices(goto_modelt &goto_model, const abstraction_spect &a
1333
1333
}
1334
1334
}
1335
1335
1336
- void insert_shape_assumptions (goto_modelt &goto_model, const abstraction_spect &abst_spec)
1336
+ void am_abstractiont:: insert_shape_assumptions (goto_modelt &goto_model, const abstraction_spect &abst_spec)
1337
1337
{
1338
-
1339
-
1340
1338
namespacet ns (goto_model.get_symbol_table ());
1341
1339
for (const auto &spec: abst_spec.get_specs ())
1342
1340
{
@@ -1359,7 +1357,7 @@ void insert_shape_assumptions(goto_modelt &goto_model, const abstraction_spect &
1359
1357
}
1360
1358
}
1361
1359
1362
- void add_length_assumptions (goto_modelt &goto_model, const abstraction_spect &abst_spec)
1360
+ void am_abstractiont:: add_length_assumptions (goto_modelt &goto_model, const abstraction_spect &abst_spec)
1363
1361
{
1364
1362
for (const auto &spec: abst_spec.get_specs ())
1365
1363
{
@@ -1447,7 +1445,7 @@ void add_length_assumptions(goto_modelt &goto_model, const abstraction_spect &ab
1447
1445
}
1448
1446
}
1449
1447
1450
- void abstract_goto_program (goto_modelt &goto_model, abstraction_spect &abst_spec)
1448
+ void am_abstractiont:: abstract_goto_program (goto_modelt &goto_model, abstraction_spect &abst_spec)
1451
1449
{
1452
1450
// Define the global concrete indices to be used
1453
1451
define_concrete_indices (goto_model, abst_spec);
@@ -1559,6 +1557,7 @@ void abstract_goto_program(goto_modelt &goto_model, abstraction_spect &abst_spec
1559
1557
new_rhs = as.rhs ();
1560
1558
}
1561
1559
1560
+ // TODO: when lhs and rhs are not both abstracted, we should do the translation.
1562
1561
code_assignt new_as (new_lhs, new_rhs);
1563
1562
it->set_assign (new_as);
1564
1563
}
@@ -1577,7 +1576,7 @@ void abstract_goto_program(goto_modelt &goto_model, abstraction_spect &abst_spec
1577
1576
if (
1578
1577
!it->is_decl () && !it->is_end_function () && !it->is_goto () &&
1579
1578
!it->is_return () && !it->is_function_call () && !it->is_assert () &&
1580
- !it->is_assign () && !it->is_assume () && !it->is_dead ())
1579
+ !it->is_assign () && !it->is_assume () && !it->is_dead () && !it-> is_skip () )
1581
1580
throw " Unknown instruction type " + std::to_string (it->type );
1582
1581
1583
1582
// insert new instructions before it
0 commit comments