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