@@ -1455,19 +1455,12 @@ void code_contractst::add_contract_check(
1455
1455
auto requires_contract = code_type.requires_contract ();
1456
1456
auto ensures_contract = code_type.ensures_contract ();
1457
1457
// build:
1458
- // if(nondet)
1459
- // decl ret
1460
- // decl parameter1 ...
1461
- // decl history_parameter1 ... [optional]
1462
- // assume(requires) [optional]
1463
- // ret=function(parameter1, ...)
1464
- // assert(ensures)
1465
- // skip: ...
1466
-
1467
- // build skip so that if(nondet) can refer to it
1468
- goto_programt tmp_skip;
1469
- goto_programt::targett skip =
1470
- tmp_skip.add (goto_programt::make_skip (ensures.source_location ()));
1458
+ // decl ret
1459
+ // decl parameter1 ...
1460
+ // decl history_parameter1 ... [optional]
1461
+ // assume(requires) [optional]
1462
+ // ret=function(parameter1, ...)
1463
+ // assert(ensures)
1471
1464
1472
1465
goto_programt check;
1473
1466
@@ -1480,17 +1473,19 @@ void code_contractst::add_contract_check(
1480
1473
// This object tracks replacements that are common to ENSURES and REQUIRES.
1481
1474
replace_symbolt common_replace;
1482
1475
1476
+ const auto &source_location = function_symbol.location ;
1477
+
1483
1478
// decl ret
1484
1479
optionalt<code_returnt> return_stmt;
1485
1480
if (code_type.return_type () != empty_typet ())
1486
1481
{
1487
1482
symbol_exprt r = new_tmp_symbol (
1488
1483
code_type.return_type (),
1489
- skip-> source_location () ,
1484
+ source_location,
1490
1485
function_symbol.mode ,
1491
1486
symbol_table)
1492
1487
.symbol_expr ();
1493
- check.add (goto_programt::make_decl (r, skip-> source_location () ));
1488
+ check.add (goto_programt::make_decl (r, source_location));
1494
1489
1495
1490
call.lhs () = r;
1496
1491
return_stmt = code_returnt (r);
@@ -1511,13 +1506,13 @@ void code_contractst::add_contract_check(
1511
1506
const symbolt ¶meter_symbol = ns.lookup (parameter);
1512
1507
symbol_exprt p = new_tmp_symbol (
1513
1508
parameter_symbol.type ,
1514
- skip-> source_location () ,
1509
+ source_location,
1515
1510
parameter_symbol.mode ,
1516
1511
symbol_table)
1517
1512
.symbol_expr ();
1518
- check.add (goto_programt::make_decl (p, skip-> source_location () ));
1513
+ check.add (goto_programt::make_decl (p, source_location));
1519
1514
check.add (goto_programt::make_assignment (
1520
- p, parameter_symbol.symbol_expr (), skip-> source_location () ));
1515
+ p, parameter_symbol.symbol_expr (), source_location));
1521
1516
1522
1517
call.arguments ().push_back (p);
1523
1518
@@ -1579,7 +1574,7 @@ void code_contractst::add_contract_check(
1579
1574
}
1580
1575
1581
1576
// ret=mangled_function(parameter1, ...)
1582
- check.add (goto_programt::make_function_call (call, skip-> source_location () ));
1577
+ check.add (goto_programt::make_function_call (call, source_location));
1583
1578
1584
1579
// Generate: assert(ensures)
1585
1580
if (ensures.is_not_nil ())
@@ -1600,15 +1595,12 @@ void code_contractst::add_contract_check(
1600
1595
if (code_type.return_type () != empty_typet ())
1601
1596
{
1602
1597
check.add (goto_programt::make_set_return_value (
1603
- return_stmt.value ().return_value (), skip-> source_location () ));
1598
+ return_stmt.value ().return_value (), source_location));
1604
1599
}
1605
1600
1606
1601
// kill the is_fresh memory map
1607
1602
visitor.add_memory_map_dead (check);
1608
1603
1609
- // add final instruction
1610
- check.destructive_append (tmp_skip);
1611
-
1612
1604
// prepend the new code to dest
1613
1605
dest.destructive_insert (dest.instructions .begin (), check);
1614
1606
0 commit comments