@@ -1455,19 +1455,12 @@ void code_contractst::add_contract_check(
14551455 auto requires_contract = code_type.requires_contract ();
14561456 auto ensures_contract = code_type.ensures_contract ();
14571457 // 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)
14711464
14721465 goto_programt check;
14731466
@@ -1480,17 +1473,19 @@ void code_contractst::add_contract_check(
14801473 // This object tracks replacements that are common to ENSURES and REQUIRES.
14811474 replace_symbolt common_replace;
14821475
1476+ const auto &source_location = function_symbol.location ;
1477+
14831478 // decl ret
14841479 optionalt<code_returnt> return_stmt;
14851480 if (code_type.return_type () != empty_typet ())
14861481 {
14871482 symbol_exprt r = new_tmp_symbol (
14881483 code_type.return_type (),
1489- skip-> source_location () ,
1484+ source_location,
14901485 function_symbol.mode ,
14911486 symbol_table)
14921487 .symbol_expr ();
1493- check.add (goto_programt::make_decl (r, skip-> source_location () ));
1488+ check.add (goto_programt::make_decl (r, source_location));
14941489
14951490 call.lhs () = r;
14961491 return_stmt = code_returnt (r);
@@ -1511,13 +1506,13 @@ void code_contractst::add_contract_check(
15111506 const symbolt ¶meter_symbol = ns.lookup (parameter);
15121507 symbol_exprt p = new_tmp_symbol (
15131508 parameter_symbol.type ,
1514- skip-> source_location () ,
1509+ source_location,
15151510 parameter_symbol.mode ,
15161511 symbol_table)
15171512 .symbol_expr ();
1518- check.add (goto_programt::make_decl (p, skip-> source_location () ));
1513+ check.add (goto_programt::make_decl (p, source_location));
15191514 check.add (goto_programt::make_assignment (
1520- p, parameter_symbol.symbol_expr (), skip-> source_location () ));
1515+ p, parameter_symbol.symbol_expr (), source_location));
15211516
15221517 call.arguments ().push_back (p);
15231518
@@ -1579,7 +1574,7 @@ void code_contractst::add_contract_check(
15791574 }
15801575
15811576 // 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));
15831578
15841579 // Generate: assert(ensures)
15851580 if (ensures.is_not_nil ())
@@ -1600,15 +1595,12 @@ void code_contractst::add_contract_check(
16001595 if (code_type.return_type () != empty_typet ())
16011596 {
16021597 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));
16041599 }
16051600
16061601 // kill the is_fresh memory map
16071602 visitor.add_memory_map_dead (check);
16081603
1609- // add final instruction
1610- check.destructive_append (tmp_skip);
1611-
16121604 // prepend the new code to dest
16131605 dest.destructive_insert (dest.instructions .begin (), check);
16141606
0 commit comments