28
28
#include < util/cprover_prefix.h>
29
29
#include < util/options.h>
30
30
31
- #include < langapi/language_util.h>
31
+ #include < langapi/language.h>
32
+ #include < langapi/mode.h>
32
33
33
34
#include " local_bitvector_analysis.h"
34
35
@@ -80,9 +81,8 @@ class goto_checkt
80
81
void check_rec (
81
82
const exprt &expr,
82
83
guardt &guard,
83
- bool address,
84
- const irep_idt &mode);
85
- void check (const exprt &expr, const irep_idt &mode);
84
+ bool address);
85
+ void check (const exprt &expr);
86
86
87
87
void bounds_check (const index_exprt &expr, const guardt &guard);
88
88
void div_by_zero_check (const div_exprt &expr, const guardt &guard);
@@ -94,8 +94,7 @@ class goto_checkt
94
94
const dereference_exprt &expr,
95
95
const guardt &guard,
96
96
const exprt &access_lb,
97
- const exprt &access_ub,
98
- const irep_idt &mode);
97
+ const exprt &access_ub);
99
98
void integer_overflow_check (const exprt &expr, const guardt &guard);
100
99
void conversion_check (const exprt &expr, const guardt &guard);
101
100
void float_overflow_check (const exprt &expr, const guardt &guard);
@@ -141,6 +140,8 @@ class goto_checkt
141
140
typedef std::pair<exprt, exprt> allocationt;
142
141
typedef std::list<allocationt> allocationst;
143
142
allocationst allocations;
143
+
144
+ irep_idt mode;
144
145
};
145
146
146
147
void goto_checkt::collect_allocations (
@@ -917,8 +918,7 @@ void goto_checkt::pointer_validity_check(
917
918
const dereference_exprt &expr,
918
919
const guardt &guard,
919
920
const exprt &access_lb,
920
- const exprt &access_ub,
921
- const irep_idt &mode)
921
+ const exprt &access_ub)
922
922
{
923
923
if (!enable_pointer_check)
924
924
return ;
@@ -1274,7 +1274,8 @@ void goto_checkt::add_guarded_claim(
1274
1274
1275
1275
goto_programt::targett t=new_code.add_instruction (type);
1276
1276
1277
- std::string source_expr_string=from_expr (ns, " " , src_expr);
1277
+ std::string source_expr_string;
1278
+ get_language_from_mode (mode)->from_expr (src_expr, source_expr_string, ns);
1278
1279
1279
1280
t->guard .swap (new_expr);
1280
1281
t->source_location =source_location;
@@ -1283,11 +1284,7 @@ void goto_checkt::add_guarded_claim(
1283
1284
}
1284
1285
}
1285
1286
1286
- void goto_checkt::check_rec (
1287
- const exprt &expr,
1288
- guardt &guard,
1289
- bool address,
1290
- const irep_idt &mode)
1287
+ void goto_checkt::check_rec (const exprt &expr, guardt &guard, bool address)
1291
1288
{
1292
1289
// we don't look into quantifiers
1293
1290
if (expr.id ()==ID_exists || expr.id ()==ID_forall)
@@ -1298,26 +1295,26 @@ void goto_checkt::check_rec(
1298
1295
if (expr.id ()==ID_dereference)
1299
1296
{
1300
1297
assert (expr.operands ().size ()==1 );
1301
- check_rec (expr.op0 (), guard, false , mode );
1298
+ check_rec (expr.op0 (), guard, false );
1302
1299
}
1303
1300
else if (expr.id ()==ID_index)
1304
1301
{
1305
1302
assert (expr.operands ().size ()==2 );
1306
- check_rec (expr.op0 (), guard, true , mode );
1307
- check_rec (expr.op1 (), guard, false , mode );
1303
+ check_rec (expr.op0 (), guard, true );
1304
+ check_rec (expr.op1 (), guard, false );
1308
1305
}
1309
1306
else
1310
1307
{
1311
1308
forall_operands (it, expr)
1312
- check_rec (*it, guard, true , mode );
1309
+ check_rec (*it, guard, true );
1313
1310
}
1314
1311
return ;
1315
1312
}
1316
1313
1317
1314
if (expr.id ()==ID_address_of)
1318
1315
{
1319
1316
assert (expr.operands ().size ()==1 );
1320
- check_rec (expr.op0 (), guard, true , mode );
1317
+ check_rec (expr.op0 (), guard, true );
1321
1318
return ;
1322
1319
}
1323
1320
else if (expr.id ()==ID_and || expr.id ()==ID_or)
@@ -1334,7 +1331,7 @@ void goto_checkt::check_rec(
1334
1331
throw " `" +expr.id_string ()+" ' takes Boolean operands only, but got " +
1335
1332
op.pretty ();
1336
1333
1337
- check_rec (op, guard, false , mode );
1334
+ check_rec (op, guard, false );
1338
1335
1339
1336
if (expr.id ()==ID_or)
1340
1337
guard.add (not_exprt (op));
@@ -1359,19 +1356,19 @@ void goto_checkt::check_rec(
1359
1356
throw msg;
1360
1357
}
1361
1358
1362
- check_rec (expr.op0 (), guard, false , mode );
1359
+ check_rec (expr.op0 (), guard, false );
1363
1360
1364
1361
{
1365
1362
guardt old_guard=guard;
1366
1363
guard.add (expr.op0 ());
1367
- check_rec (expr.op1 (), guard, false , mode );
1364
+ check_rec (expr.op1 (), guard, false );
1368
1365
guard.swap (old_guard);
1369
1366
}
1370
1367
1371
1368
{
1372
1369
guardt old_guard=guard;
1373
1370
guard.add (not_exprt (expr.op0 ()));
1374
- check_rec (expr.op2 (), guard, false , mode );
1371
+ check_rec (expr.op2 (), guard, false );
1375
1372
guard.swap (old_guard);
1376
1373
}
1377
1374
@@ -1384,7 +1381,7 @@ void goto_checkt::check_rec(
1384
1381
const dereference_exprt &deref=
1385
1382
to_dereference_expr (member.struct_op ());
1386
1383
1387
- check_rec (deref.op0 (), guard, false , mode );
1384
+ check_rec (deref.op0 (), guard, false );
1388
1385
1389
1386
exprt access_ub=nil_exprt ();
1390
1387
@@ -1394,13 +1391,13 @@ void goto_checkt::check_rec(
1394
1391
if (member_offset.is_not_nil () && size.is_not_nil ())
1395
1392
access_ub=plus_exprt (member_offset, size);
1396
1393
1397
- pointer_validity_check (deref, guard, member_offset, access_ub, mode );
1394
+ pointer_validity_check (deref, guard, member_offset, access_ub);
1398
1395
1399
1396
return ;
1400
1397
}
1401
1398
1402
1399
forall_operands (it, expr)
1403
- check_rec (*it, guard, false , mode );
1400
+ check_rec (*it, guard, false );
1404
1401
1405
1402
if (expr.id ()==ID_index)
1406
1403
{
@@ -1462,21 +1459,21 @@ void goto_checkt::check_rec(
1462
1459
to_dereference_expr (expr),
1463
1460
guard,
1464
1461
nil_exprt (),
1465
- size_of_expr (expr.type (), ns),
1466
- mode);
1462
+ size_of_expr (expr.type (), ns));
1467
1463
}
1468
1464
1469
- void goto_checkt::check (const exprt &expr, const irep_idt &mode )
1465
+ void goto_checkt::check (const exprt &expr)
1470
1466
{
1471
1467
guardt guard;
1472
- check_rec (expr, guard, false , mode );
1468
+ check_rec (expr, guard, false );
1473
1469
}
1474
1470
1475
1471
void goto_checkt::goto_check (
1476
1472
goto_functiont &goto_function,
1477
- const irep_idt &mode )
1473
+ const irep_idt &_mode )
1478
1474
{
1479
1475
assertions.clear ();
1476
+ mode = _mode;
1480
1477
1481
1478
local_bitvector_analysist local_bitvector_analysis_obj (goto_function);
1482
1479
local_bitvector_analysis=&local_bitvector_analysis_obj;
@@ -1497,7 +1494,7 @@ void goto_checkt::goto_check(
1497
1494
i.is_target ())
1498
1495
assertions.clear ();
1499
1496
1500
- check (i.guard , mode );
1497
+ check (i.guard );
1501
1498
1502
1499
// magic ERROR label?
1503
1500
for (const auto &label : error_labels)
@@ -1523,20 +1520,20 @@ void goto_checkt::goto_check(
1523
1520
1524
1521
if (statement==ID_expression)
1525
1522
{
1526
- check (i.code , mode );
1523
+ check (i.code );
1527
1524
}
1528
1525
else if (statement==ID_printf)
1529
1526
{
1530
1527
forall_operands (it, i.code )
1531
- check (*it, mode );
1528
+ check (*it);
1532
1529
}
1533
1530
}
1534
1531
else if (i.is_assign ())
1535
1532
{
1536
1533
const code_assignt &code_assign=to_code_assign (i.code );
1537
1534
1538
- check (code_assign.lhs (), mode );
1539
- check (code_assign.rhs (), mode );
1535
+ check (code_assign.lhs ());
1536
+ check (code_assign.rhs ());
1540
1537
1541
1538
// the LHS might invalidate any assertion
1542
1539
invalidate (code_assign.lhs ());
@@ -1576,7 +1573,7 @@ void goto_checkt::goto_check(
1576
1573
}
1577
1574
1578
1575
forall_operands (it, code_function_call)
1579
- check (*it, mode );
1576
+ check (*it);
1580
1577
1581
1578
// the call might invalidate any assertion
1582
1579
assertions.clear ();
@@ -1585,7 +1582,7 @@ void goto_checkt::goto_check(
1585
1582
{
1586
1583
if (i.code .operands ().size ()==1 )
1587
1584
{
1588
- check (i.code .op0 (), mode );
1585
+ check (i.code .op0 ());
1589
1586
// the return value invalidate any assertion
1590
1587
invalidate (i.code .op0 ());
1591
1588
}
0 commit comments