@@ -62,17 +62,19 @@ class goto_checkt
62
62
63
63
typedef goto_functionst::goto_functiont goto_functiont;
64
64
65
- void goto_check (goto_functiont &goto_function);
66
-
67
- irep_idt mode;
65
+ void goto_check (goto_functiont &goto_function, const irep_idt &mode);
68
66
69
67
protected:
70
68
const namespacet &ns;
71
69
local_bitvector_analysist *local_bitvector_analysis;
72
70
goto_programt::const_targett t;
73
71
74
- void check_rec (const exprt &expr, guardt &guard, bool address);
75
- void check (const exprt &expr);
72
+ void check_rec (
73
+ const exprt &expr,
74
+ guardt &guard,
75
+ bool address,
76
+ const irep_idt &mode);
77
+ void check (const exprt &expr, const irep_idt &mode);
76
78
77
79
void bounds_check (const index_exprt &expr, const guardt &guard);
78
80
void div_by_zero_check (const div_exprt &expr, const guardt &guard);
@@ -84,7 +86,8 @@ class goto_checkt
84
86
const dereference_exprt &expr,
85
87
const guardt &guard,
86
88
const exprt &access_lb,
87
- const exprt &access_ub);
89
+ const exprt &access_ub,
90
+ const irep_idt &mode);
88
91
void integer_overflow_check (const exprt &expr, const guardt &guard);
89
92
void conversion_check (const exprt &expr, const guardt &guard);
90
93
void float_overflow_check (const exprt &expr, const guardt &guard);
@@ -993,9 +996,10 @@ void goto_checkt::pointer_validity_check(
993
996
const dereference_exprt &expr,
994
997
const guardt &guard,
995
998
const exprt &access_lb,
996
- const exprt &access_ub)
999
+ const exprt &access_ub,
1000
+ const irep_idt &mode)
997
1001
{
998
- if (!enable_pointer_check)
1002
+ if (mode!=ID_java && !enable_pointer_check)
999
1003
return ;
1000
1004
1001
1005
const exprt &pointer=expr.op0 ();
@@ -1373,7 +1377,8 @@ Function: goto_checkt::check_rec
1373
1377
void goto_checkt::check_rec (
1374
1378
const exprt &expr,
1375
1379
guardt &guard,
1376
- bool address)
1380
+ bool address,
1381
+ const irep_idt &mode)
1377
1382
{
1378
1383
// we don't look into quantifiers
1379
1384
if (expr.id ()==ID_exists || expr.id ()==ID_forall)
@@ -1384,26 +1389,26 @@ void goto_checkt::check_rec(
1384
1389
if (expr.id ()==ID_dereference)
1385
1390
{
1386
1391
assert (expr.operands ().size ()==1 );
1387
- check_rec (expr.op0 (), guard, false );
1392
+ check_rec (expr.op0 (), guard, false , mode );
1388
1393
}
1389
1394
else if (expr.id ()==ID_index)
1390
1395
{
1391
1396
assert (expr.operands ().size ()==2 );
1392
- check_rec (expr.op0 (), guard, true );
1393
- check_rec (expr.op1 (), guard, false );
1397
+ check_rec (expr.op0 (), guard, true , mode );
1398
+ check_rec (expr.op1 (), guard, false , mode );
1394
1399
}
1395
1400
else
1396
1401
{
1397
1402
forall_operands (it, expr)
1398
- check_rec (*it, guard, true );
1403
+ check_rec (*it, guard, true , mode );
1399
1404
}
1400
1405
return ;
1401
1406
}
1402
1407
1403
1408
if (expr.id ()==ID_address_of)
1404
1409
{
1405
1410
assert (expr.operands ().size ()==1 );
1406
- check_rec (expr.op0 (), guard, true );
1411
+ check_rec (expr.op0 (), guard, true , mode );
1407
1412
return ;
1408
1413
}
1409
1414
else if (expr.id ()==ID_and || expr.id ()==ID_or)
@@ -1420,7 +1425,7 @@ void goto_checkt::check_rec(
1420
1425
throw " `" +expr.id_string ()+" ' takes Boolean operands only, but got " +
1421
1426
op.pretty ();
1422
1427
1423
- check_rec (op, guard, false );
1428
+ check_rec (op, guard, false , mode );
1424
1429
1425
1430
if (expr.id ()==ID_or)
1426
1431
guard.add (not_exprt (op));
@@ -1445,19 +1450,19 @@ void goto_checkt::check_rec(
1445
1450
throw msg;
1446
1451
}
1447
1452
1448
- check_rec (expr.op0 (), guard, false );
1453
+ check_rec (expr.op0 (), guard, false , mode );
1449
1454
1450
1455
{
1451
1456
guardt old_guard=guard;
1452
1457
guard.add (expr.op0 ());
1453
- check_rec (expr.op1 (), guard, false );
1458
+ check_rec (expr.op1 (), guard, false , mode );
1454
1459
guard.swap (old_guard);
1455
1460
}
1456
1461
1457
1462
{
1458
1463
guardt old_guard=guard;
1459
1464
guard.add (not_exprt (expr.op0 ()));
1460
- check_rec (expr.op2 (), guard, false );
1465
+ check_rec (expr.op2 (), guard, false , mode );
1461
1466
guard.swap (old_guard);
1462
1467
}
1463
1468
@@ -1470,7 +1475,7 @@ void goto_checkt::check_rec(
1470
1475
const dereference_exprt &deref=
1471
1476
to_dereference_expr (member.struct_op ());
1472
1477
1473
- check_rec (deref.op0 (), guard, false );
1478
+ check_rec (deref.op0 (), guard, false , mode );
1474
1479
1475
1480
exprt access_ub=nil_exprt ();
1476
1481
@@ -1480,13 +1485,13 @@ void goto_checkt::check_rec(
1480
1485
if (member_offset.is_not_nil () && size.is_not_nil ())
1481
1486
access_ub=plus_exprt (member_offset, size);
1482
1487
1483
- pointer_validity_check (deref, guard, member_offset, access_ub);
1488
+ pointer_validity_check (deref, guard, member_offset, access_ub, mode );
1484
1489
1485
1490
return ;
1486
1491
}
1487
1492
1488
1493
forall_operands (it, expr)
1489
- check_rec (*it, guard, false );
1494
+ check_rec (*it, guard, false , mode );
1490
1495
1491
1496
if (expr.id ()==ID_index)
1492
1497
{
@@ -1545,7 +1550,8 @@ void goto_checkt::check_rec(
1545
1550
to_dereference_expr (expr),
1546
1551
guard,
1547
1552
nil_exprt (),
1548
- size_of_expr (expr.type (), ns));
1553
+ size_of_expr (expr.type (), ns),
1554
+ mode);
1549
1555
}
1550
1556
1551
1557
/* ******************************************************************\
@@ -1560,10 +1566,10 @@ Function: goto_checkt::check
1560
1566
1561
1567
\*******************************************************************/
1562
1568
1563
- void goto_checkt::check (const exprt &expr)
1569
+ void goto_checkt::check (const exprt &expr, const irep_idt &mode )
1564
1570
{
1565
1571
guardt guard;
1566
- check_rec (expr, guard, false );
1572
+ check_rec (expr, guard, false , mode );
1567
1573
}
1568
1574
1569
1575
/* ******************************************************************\
@@ -1574,18 +1580,14 @@ Function: goto_checkt::goto_check
1574
1580
1575
1581
Outputs:
1576
1582
1577
- Purpose:[B
1583
+ Purpose:
1578
1584
1579
1585
\*******************************************************************/
1580
1586
1581
- void goto_checkt::goto_check (goto_functiont &goto_function)
1587
+ void goto_checkt::goto_check (
1588
+ goto_functiont &goto_function,
1589
+ const irep_idt &mode)
1582
1590
{
1583
- {
1584
- const symbolt *init_symbol;
1585
- if (!ns.lookup (CPROVER_PREFIX " initialize" , init_symbol))
1586
- mode=init_symbol->mode ;
1587
- }
1588
-
1589
1591
assertions.clear ();
1590
1592
1591
1593
local_bitvector_analysist local_bitvector_analysis_obj (goto_function);
@@ -1607,7 +1609,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
1607
1609
i.is_target ())
1608
1610
assertions.clear ();
1609
1611
1610
- check (i.guard );
1612
+ check (i.guard , mode );
1611
1613
1612
1614
// magic ERROR label?
1613
1615
for (const auto &label : error_labels)
@@ -1633,20 +1635,20 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
1633
1635
1634
1636
if (statement==ID_expression)
1635
1637
{
1636
- check (i.code );
1638
+ check (i.code , mode );
1637
1639
}
1638
1640
else if (statement==ID_printf)
1639
1641
{
1640
1642
forall_operands (it, i.code )
1641
- check (*it);
1643
+ check (*it, mode );
1642
1644
}
1643
1645
}
1644
1646
else if (i.is_assign ())
1645
1647
{
1646
1648
const code_assignt &code_assign=to_code_assign (i.code );
1647
1649
1648
- check (code_assign.lhs ());
1649
- check (code_assign.rhs ());
1650
+ check (code_assign.lhs (), mode );
1651
+ check (code_assign.rhs (), mode );
1650
1652
1651
1653
// the LHS might invalidate any assertion
1652
1654
invalidate (code_assign.lhs ());
@@ -1686,7 +1688,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
1686
1688
}
1687
1689
1688
1690
forall_operands (it, code_function_call)
1689
- check (*it);
1691
+ check (*it, mode );
1690
1692
1691
1693
// the call might invalidate any assertion
1692
1694
assertions.clear ();
@@ -1695,7 +1697,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
1695
1697
{
1696
1698
if (i.code .operands ().size ()==1 )
1697
1699
{
1698
- check (i.code .op0 ());
1700
+ check (i.code .op0 (), mode );
1699
1701
// the return value invalidate any assertion
1700
1702
invalidate (i.code .op0 ());
1701
1703
}
@@ -1853,7 +1855,7 @@ void goto_check(
1853
1855
goto_functionst::goto_functiont &goto_function)
1854
1856
{
1855
1857
goto_checkt goto_check (ns, options);
1856
- goto_check.goto_check (goto_function);
1858
+ goto_check.goto_check (goto_function, irep_idt () );
1857
1859
}
1858
1860
1859
1861
/* ******************************************************************\
@@ -1877,7 +1879,8 @@ void goto_check(
1877
1879
1878
1880
Forall_goto_functions (it, goto_functions)
1879
1881
{
1880
- goto_check.goto_check (it->second );
1882
+ irep_idt mode=ns.lookup (it->first ).mode ;
1883
+ goto_check.goto_check (it->second , mode);
1881
1884
}
1882
1885
}
1883
1886
@@ -1898,10 +1901,5 @@ void goto_check(
1898
1901
goto_modelt &goto_model)
1899
1902
{
1900
1903
const namespacet ns (goto_model.symbol_table );
1901
- goto_checkt goto_check (ns, options);
1902
-
1903
- Forall_goto_functions (it, goto_model.goto_functions )
1904
- {
1905
- goto_check.goto_check (it->second );
1906
- }
1904
+ goto_check (ns, options, goto_model.goto_functions );
1907
1905
}
0 commit comments