@@ -1542,11 +1542,38 @@ goto_programt assigns_clauset::havoc_code(
1542
1542
goto_programt havoc_statements;
1543
1543
for (assigns_clause_targett *target : targets)
1544
1544
{
1545
+ // if(target != NULL) goto x;
1546
+ // havoc_statements
1547
+ // z: skip
1548
+
1549
+ // create the z label
1550
+ goto_programt tmp_z;
1551
+ goto_programt::targett z = tmp_z.add (goto_programt::make_skip (location));
1552
+
1553
+ // TODO: generalize this. Currently only supports pointers
1554
+ // See GitHub issue #6087 for further details
1555
+ if (target->target_type == assigns_clause_targett::target_type::Scalar)
1556
+ {
1557
+ exprt condition = equal_exprt (
1558
+ target->get_direct_pointer (),
1559
+ null_pointer_exprt (
1560
+ to_pointer_type (target->get_direct_pointer ().type ())));
1561
+
1562
+ havoc_statements.add (goto_programt::make_goto (z, condition, location));
1563
+ }
1564
+
1565
+ // create havoc_statements
1545
1566
for (goto_programt::instructiont instruction :
1546
1567
target->havoc_code (location).instructions )
1547
1568
{
1548
1569
havoc_statements.add (std::move (instruction));
1549
1570
}
1571
+
1572
+ if (target->target_type == assigns_clause_targett::target_type::Scalar)
1573
+ {
1574
+ // add the z label instruction
1575
+ havoc_statements.destructive_append (tmp_z);
1576
+ }
1550
1577
}
1551
1578
return havoc_statements;
1552
1579
}
@@ -1595,9 +1622,23 @@ exprt assigns_clauset::compatible_expression(
1595
1622
{
1596
1623
if (first_iter)
1597
1624
{
1598
- current_target_compatible =
1599
- target->compatible_expression (*called_target);
1600
- first_iter = false ;
1625
+ // TODO: generalize this. Currently only supports pointers
1626
+ // See GitHub issue #6087 for further details
1627
+ if (target->target_type == assigns_clause_targett::target_type::Scalar)
1628
+ {
1629
+ current_target_compatible = or_exprt (
1630
+ equal_exprt (
1631
+ called_target->get_direct_pointer (),
1632
+ null_pointer_exprt (
1633
+ to_pointer_type (called_target->get_direct_pointer ().type ()))),
1634
+ target->compatible_expression (*called_target));
1635
+ }
1636
+ else
1637
+ {
1638
+ current_target_compatible =
1639
+ target->compatible_expression (*called_target);
1640
+ first_iter = false ;
1641
+ }
1601
1642
}
1602
1643
else
1603
1644
{
0 commit comments