@@ -631,27 +631,18 @@ void code_contractst::replace_history_parameter(
631
631
}
632
632
}
633
633
634
- std::pair<goto_programt, goto_programt>
635
- code_contractst::create_ensures_instruction (
636
- codet &expression,
637
- source_locationt location,
638
- const irep_idt &mode)
634
+ void code_contractst::generate_history_variables_initialization (
635
+ exprt &clause,
636
+ const irep_idt &mode,
637
+ goto_programt &program)
639
638
{
640
639
std::map<exprt, exprt> parameter2history;
641
640
goto_programt history;
642
-
643
641
// Find and replace "old" expression in the "expression" variable
644
642
replace_history_parameter (
645
- expression, parameter2history, location, mode, history, ID_old);
646
-
647
- // Create instructions corresponding to the ensures clause
648
- goto_programt ensures_program;
649
- converter.goto_convert (expression, ensures_program, mode);
650
-
651
- // return a pair containing:
652
- // 1. instructions corresponding to the ensures clause
653
- // 2. instructions related to initializing the history variables
654
- return std::make_pair (std::move (ensures_program), std::move (history));
643
+ clause, parameter2history, clause.source_location (), mode, history, ID_old);
644
+ // Add all the history variable initialization instructions
645
+ program.destructive_append (history);
655
646
}
656
647
657
648
// / This function generates instructions for all contract constraint, i.e.,
@@ -835,26 +826,16 @@ void code_contractst::apply_function_contract(
835
826
new_program);
836
827
}
837
828
838
- // Gather all the instructions required to handle history variables
839
- std::vector<exprt> instantiated_ensures_clauses;
829
+ // Generate all the instructions required to initialize history variables
830
+ exprt::operandst instantiated_ensures_clauses;
840
831
for (auto clause : type.ensures ())
841
832
{
842
833
auto instantiated_clause =
843
834
to_lambda_expr (clause).application (instantiation_values);
844
835
instantiated_clause.add_source_location () = clause.source_location ();
845
- std::map<exprt, exprt> parameter2history;
846
- goto_programt history;
847
- // Find and replace "old" expression in the "expression" variable
848
- replace_history_parameter (
849
- instantiated_clause,
850
- parameter2history,
851
- clause.source_location (),
852
- mode,
853
- history,
854
- ID_old);
836
+ generate_history_variables_initialization (
837
+ instantiated_clause, mode, new_program);
855
838
instantiated_ensures_clauses.push_back (instantiated_clause);
856
- // Add all the history variable initialization instructions
857
- new_program.destructive_append (history);
858
839
}
859
840
860
841
// ASSIGNS clause should not refer to any quantified variables,
@@ -1504,26 +1485,16 @@ void code_contractst::add_contract_check(
1504
1485
_location);
1505
1486
}
1506
1487
1507
- // Gather all the instructions required to handle history variables
1508
- std::vector<exprt> instantiated_ensures_clauses;
1488
+ // Generate all the instructions required to initialize history variables
1489
+ exprt::operandst instantiated_ensures_clauses;
1509
1490
for (auto clause : code_type.ensures ())
1510
1491
{
1511
1492
auto instantiated_clause =
1512
1493
to_lambda_expr (clause).application (instantiation_values);
1513
1494
instantiated_clause.add_source_location () = clause.source_location ();
1514
- std::map<exprt, exprt> parameter2history;
1515
- goto_programt history;
1516
- // Find and replace "old" expression in the "expression" variable
1517
- replace_history_parameter (
1518
- instantiated_clause,
1519
- parameter2history,
1520
- clause.source_location (),
1521
- function_symbol.mode ,
1522
- history,
1523
- ID_old);
1495
+ generate_history_variables_initialization (
1496
+ instantiated_clause, function_symbol.mode , check);
1524
1497
instantiated_ensures_clauses.push_back (instantiated_clause);
1525
- // Add all the history variable initialization instructions
1526
- check.destructive_append (history);
1527
1498
}
1528
1499
1529
1500
// Translate requires_contract(ptr, contract) clauses to assumptions
0 commit comments