Skip to content

Commit b465e80

Browse files
authored
Merge pull request #8282 from qinheping/bugfixes/use_fresh_converter_in_contracts
[CONTRACTS] Use fresh converter in loop contracts instrumentation
2 parents 621fe05 + 7273894 commit b465e80

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/goto-instrument/contracts/contracts.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ void code_contractst::check_apply_loop_contracts(
173173
initial_invariant_val, invariant};
174174
initial_invariant_value_assignment.add_source_location() =
175175
loop_head_location;
176+
177+
goto_convertt converter(symbol_table, log.get_message_handler());
176178
converter.goto_convert(
177179
initial_invariant_value_assignment, pre_loop_head_instrs, mode);
178180
}
@@ -293,6 +295,8 @@ void code_contractst::check_apply_loop_contracts(
293295
assertion.add_source_location() = loop_head_location;
294296
assertion.add_source_location().set_comment(
295297
"Check loop invariant before entry");
298+
299+
goto_convertt converter(symbol_table, log.get_message_handler());
296300
converter.goto_convert(assertion, pre_loop_head_instrs, mode);
297301
}
298302

@@ -338,6 +342,8 @@ void code_contractst::check_apply_loop_contracts(
338342
{
339343
code_assumet assumption{invariant};
340344
assumption.add_source_location() = loop_head_location;
345+
346+
goto_convertt converter(symbol_table, log.get_message_handler());
341347
converter.goto_convert(assumption, pre_loop_head_instrs, mode);
342348
}
343349

@@ -393,6 +399,8 @@ void code_contractst::check_apply_loop_contracts(
393399
code_assignt old_decreases_assignment{
394400
old_decreases_vars[i], decreases_clause_exprs[i]};
395401
old_decreases_assignment.add_source_location() = loop_head_location;
402+
403+
goto_convertt converter(symbol_table, log.get_message_handler());
396404
converter.goto_convert(
397405
old_decreases_assignment, pre_loop_head_instrs, mode);
398406
}
@@ -441,6 +449,8 @@ void code_contractst::check_apply_loop_contracts(
441449
assertion.add_source_location() = loop_head_location;
442450
assertion.add_source_location().set_comment(
443451
"Check that loop invariant is preserved");
452+
453+
goto_convertt converter(symbol_table, log.get_message_handler());
444454
converter.goto_convert(assertion, pre_loop_end_instrs, mode);
445455
}
446456

@@ -453,6 +463,8 @@ void code_contractst::check_apply_loop_contracts(
453463
code_assignt new_decreases_assignment{
454464
new_decreases_vars[i], decreases_clause_exprs[i]};
455465
new_decreases_assignment.add_source_location() = loop_head_location;
466+
467+
goto_convertt converter(symbol_table, log.get_message_handler());
456468
converter.goto_convert(
457469
new_decreases_assignment, pre_loop_end_instrs, mode);
458470
}
@@ -465,6 +477,8 @@ void code_contractst::check_apply_loop_contracts(
465477
monotonic_decreasing_assertion.add_source_location() = loop_head_location;
466478
monotonic_decreasing_assertion.add_source_location().set_comment(
467479
"Check decreases clause on loop iteration");
480+
481+
goto_convertt converter(symbol_table, log.get_message_handler());
468482
converter.goto_convert(
469483
monotonic_decreasing_assertion, pre_loop_end_instrs, mode);
470484

@@ -706,6 +720,7 @@ void code_contractst::apply_function_contract(
706720
.append(" in ")
707721
.append(function.c_str()));
708722
_location.set_property_class(ID_precondition);
723+
goto_convertt converter(symbol_table, log.get_message_handler());
709724
generate_contract_constraints(
710725
symbol_table,
711726
converter,
@@ -785,6 +800,8 @@ void code_contractst::apply_function_contract(
785800
source_locationt _location = clause.source_location();
786801
_location.set_comment("Assume ensures clause");
787802
_location.set_property_class(ID_assume);
803+
804+
goto_convertt converter(symbol_table, log.get_message_handler());
788805
generate_contract_constraints(
789806
symbol_table,
790807
converter,
@@ -1355,6 +1372,7 @@ void code_contractst::add_contract_check(
13551372
source_locationt _location = clause.source_location();
13561373
_location.set_comment("Assume requires clause");
13571374
_location.set_property_class(ID_assume);
1375+
goto_convertt converter(symbol_table, log.get_message_handler());
13581376
generate_contract_constraints(
13591377
symbol_table,
13601378
converter,
@@ -1388,6 +1406,7 @@ void code_contractst::add_contract_check(
13881406
source_locationt _location = clause.source_location();
13891407
_location.set_comment("Check ensures clause");
13901408
_location.set_property_class(ID_postcondition);
1409+
goto_convertt converter(symbol_table, log.get_message_handler());
13911410
generate_contract_constraints(
13921411
symbol_table,
13931412
converter,

src/goto-instrument/contracts/contracts.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Date: February 2016
1414
#ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_CONTRACTS_H
1515
#define CPROVER_GOTO_INSTRUMENT_CONTRACTS_CONTRACTS_H
1616

17-
#include <ansi-c/goto-conversion/goto_convert_class.h>
18-
1917
#include <util/message.h>
2018
#include <util/namespace.h>
2119

@@ -62,8 +60,7 @@ class code_contractst
6260
goto_model(goto_model),
6361
symbol_table(goto_model.symbol_table),
6462
goto_functions(goto_model.goto_functions),
65-
log(log),
66-
converter(symbol_table, log.get_message_handler())
63+
log(log)
6764
{
6865
}
6966

@@ -150,7 +147,6 @@ class code_contractst
150147
goto_functionst &goto_functions;
151148

152149
messaget &log;
153-
goto_convertt converter;
154150

155151
std::unordered_set<irep_idt> summarized;
156152

0 commit comments

Comments
 (0)