@@ -1613,17 +1613,34 @@ void goto_convertt::convert_ifthenelse(
1613
1613
// convert 'then'-branch
1614
1614
goto_programt tmp_then;
1615
1615
convert (code.then_case (), tmp_then, mode);
1616
+ source_locationt then_end_location =
1617
+ code.then_case ().get_statement () == ID_block
1618
+ ? to_code_block (code.then_case ()).end_location ()
1619
+ : code.then_case ().source_location ();
1616
1620
1617
1621
goto_programt tmp_else;
1622
+ source_locationt else_end_location;
1618
1623
1619
1624
if (has_else)
1625
+ {
1620
1626
convert (code.else_case (), tmp_else, mode);
1627
+ else_end_location = code.else_case ().get_statement () == ID_block
1628
+ ? to_code_block (code.else_case ()).end_location ()
1629
+ : code.else_case ().source_location ();
1630
+ }
1621
1631
1622
1632
exprt tmp_guard=code.cond ();
1623
1633
clean_expr (tmp_guard, dest, mode);
1624
1634
1625
1635
generate_ifthenelse (
1626
- tmp_guard, tmp_then, tmp_else, source_location, dest, mode);
1636
+ tmp_guard,
1637
+ source_location,
1638
+ tmp_then,
1639
+ then_end_location,
1640
+ tmp_else,
1641
+ else_end_location,
1642
+ dest,
1643
+ mode);
1627
1644
}
1628
1645
1629
1646
void goto_convertt::collect_operands (
@@ -1655,9 +1672,11 @@ static inline bool is_size_one(const goto_programt &g)
1655
1672
// / if(guard) true_case; else false_case;
1656
1673
void goto_convertt::generate_ifthenelse (
1657
1674
const exprt &guard,
1675
+ const source_locationt &source_location,
1658
1676
goto_programt &true_case,
1677
+ const source_locationt &then_end_location,
1659
1678
goto_programt &false_case,
1660
- const source_locationt &source_location ,
1679
+ const source_locationt &else_end_location ,
1661
1680
goto_programt &dest,
1662
1681
const irep_idt &mode)
1663
1682
{
@@ -1727,13 +1746,17 @@ void goto_convertt::generate_ifthenelse(
1727
1746
1728
1747
// Flip around if no 'true' case code.
1729
1748
if (is_empty (true_case))
1749
+ {
1730
1750
return generate_ifthenelse (
1731
1751
boolean_negate (guard),
1752
+ source_location,
1732
1753
false_case,
1754
+ else_end_location,
1733
1755
true_case,
1734
- source_location ,
1756
+ then_end_location ,
1735
1757
dest,
1736
1758
mode);
1759
+ }
1737
1760
1738
1761
bool has_else=!is_empty (false_case);
1739
1762
@@ -1753,14 +1776,13 @@ void goto_convertt::generate_ifthenelse(
1753
1776
1754
1777
// do the x label
1755
1778
goto_programt tmp_x;
1756
- goto_programt::targett x = tmp_x.add (goto_programt::make_incomplete_goto (
1757
- true_exprt (), true_case. instructions . back (). source_location () ));
1779
+ goto_programt::targett x = tmp_x.add (
1780
+ goto_programt::make_incomplete_goto ( true_exprt (), then_end_location ));
1758
1781
1759
1782
// do the z label
1760
1783
goto_programt tmp_z;
1761
- goto_programt::targett z = tmp_z.add (goto_programt::make_skip ());
1762
- // We deliberately don't set a location for 'z', it's a dummy
1763
- // target.
1784
+ goto_programt::targett z = tmp_z.add (
1785
+ goto_programt::make_skip (has_else ? else_end_location : then_end_location));
1764
1786
1765
1787
// y: Q;
1766
1788
goto_programt tmp_y;
0 commit comments