@@ -1002,15 +1002,13 @@ inline bool can_cast_type<code_typet>(const typet &type)
1002
1002
inline const code_typet &to_code_type (const typet &type)
1003
1003
{
1004
1004
PRECONDITION (can_cast_type<code_typet>(type));
1005
- validate_type (type);
1006
1005
return static_cast <const code_typet &>(type);
1007
1006
}
1008
1007
1009
1008
// / \copydoc to_code_type(const typet &)
1010
1009
inline code_typet &to_code_type (typet &type)
1011
1010
{
1012
1011
PRECONDITION (can_cast_type<code_typet>(type));
1013
- validate_type (type);
1014
1012
return static_cast <code_typet &>(type);
1015
1013
}
1016
1014
@@ -1205,6 +1203,11 @@ class bv_typet:public bitvector_typet
1205
1203
{
1206
1204
set_width (width);
1207
1205
}
1206
+
1207
+ void check (const validation_modet vm = validation_modet::INVARIANT) const
1208
+ {
1209
+ DATA_CHECK (!get (ID_width).empty (), " bitvector type must have width" );
1210
+ }
1208
1211
};
1209
1212
1210
1213
// / Check whether a reference to a typet is a \ref bv_typet.
@@ -1216,11 +1219,6 @@ inline bool can_cast_type<bv_typet>(const typet &type)
1216
1219
return type.id () == ID_bv;
1217
1220
}
1218
1221
1219
- inline void validate_type (const bv_typet &type)
1220
- {
1221
- DATA_INVARIANT (!type.get (ID_width).empty (), " bitvector type must have width" );
1222
- }
1223
-
1224
1222
// / \brief Cast a typet to a \ref bv_typet
1225
1223
// /
1226
1224
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1233,7 +1231,7 @@ inline const bv_typet &to_bv_type(const typet &type)
1233
1231
{
1234
1232
PRECONDITION (can_cast_type<bv_typet>(type));
1235
1233
const bv_typet &ret = static_cast <const bv_typet &>(type);
1236
- validate_type ( ret);
1234
+ ret. check ( );
1237
1235
return ret;
1238
1236
}
1239
1237
@@ -1242,7 +1240,7 @@ inline bv_typet &to_bv_type(typet &type)
1242
1240
{
1243
1241
PRECONDITION (can_cast_type<bv_typet>(type));
1244
1242
bv_typet &ret = static_cast <bv_typet &>(type);
1245
- validate_type ( ret);
1243
+ ret. check ( );
1246
1244
return ret;
1247
1245
}
1248
1246
@@ -1316,6 +1314,11 @@ class signedbv_typet:public bitvector_typet
1316
1314
constant_exprt smallest_expr () const ;
1317
1315
constant_exprt zero_expr () const ;
1318
1316
constant_exprt largest_expr () const ;
1317
+
1318
+ void check (const validation_modet vm = validation_modet::INVARIANT) const
1319
+ {
1320
+ DATA_CHECK (!get (ID_width).empty (), " signed bitvector type must have width" );
1321
+ }
1319
1322
};
1320
1323
1321
1324
// / Check whether a reference to a typet is a \ref signedbv_typet.
@@ -1327,12 +1330,6 @@ inline bool can_cast_type<signedbv_typet>(const typet &type)
1327
1330
return type.id () == ID_signedbv;
1328
1331
}
1329
1332
1330
- inline void validate_type (const signedbv_typet &type)
1331
- {
1332
- DATA_INVARIANT (
1333
- !type.get (ID_width).empty (), " signed bitvector type must have width" );
1334
- }
1335
-
1336
1333
// / \brief Cast a typet to a \ref signedbv_typet
1337
1334
// /
1338
1335
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1345,7 +1342,7 @@ inline const signedbv_typet &to_signedbv_type(const typet &type)
1345
1342
{
1346
1343
PRECONDITION (can_cast_type<signedbv_typet>(type));
1347
1344
const signedbv_typet &ret = static_cast <const signedbv_typet &>(type);
1348
- validate_type ( ret);
1345
+ ret. check ( );
1349
1346
return ret;
1350
1347
}
1351
1348
@@ -1354,7 +1351,7 @@ inline signedbv_typet &to_signedbv_type(typet &type)
1354
1351
{
1355
1352
PRECONDITION (can_cast_type<signedbv_typet>(type));
1356
1353
signedbv_typet &ret = static_cast <signedbv_typet &>(type);
1357
- validate_type ( ret);
1354
+ ret. check ( );
1358
1355
return ret;
1359
1356
}
1360
1357
@@ -1380,6 +1377,11 @@ class fixedbv_typet:public bitvector_typet
1380
1377
{
1381
1378
set (ID_integer_bits, b);
1382
1379
}
1380
+
1381
+ void check (const validation_modet vm = validation_modet::INVARIANT) const
1382
+ {
1383
+ DATA_CHECK (!get (ID_width).empty (), " fixed bitvector type must have width" );
1384
+ }
1383
1385
};
1384
1386
1385
1387
// / Check whether a reference to a typet is a \ref fixedbv_typet.
@@ -1391,12 +1393,6 @@ inline bool can_cast_type<fixedbv_typet>(const typet &type)
1391
1393
return type.id () == ID_fixedbv;
1392
1394
}
1393
1395
1394
- inline void validate_type (const fixedbv_typet &type)
1395
- {
1396
- DATA_INVARIANT (
1397
- !type.get (ID_width).empty (), " fixed bitvector type must have width" );
1398
- }
1399
-
1400
1396
// / \brief Cast a typet to a \ref fixedbv_typet
1401
1397
// /
1402
1398
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1409,7 +1405,7 @@ inline const fixedbv_typet &to_fixedbv_type(const typet &type)
1409
1405
{
1410
1406
PRECONDITION (can_cast_type<fixedbv_typet>(type));
1411
1407
const fixedbv_typet &ret = static_cast <const fixedbv_typet &>(type);
1412
- validate_type ( ret);
1408
+ ret. check ( );
1413
1409
return ret;
1414
1410
}
1415
1411
@@ -1418,7 +1414,7 @@ inline fixedbv_typet &to_fixedbv_type(typet &type)
1418
1414
{
1419
1415
PRECONDITION (can_cast_type<fixedbv_typet>(type));
1420
1416
fixedbv_typet &ret = static_cast <fixedbv_typet &>(type);
1421
- validate_type ( ret);
1417
+ ret. check ( );
1422
1418
return ret;
1423
1419
}
1424
1420
@@ -1442,6 +1438,11 @@ class floatbv_typet:public bitvector_typet
1442
1438
{
1443
1439
set (ID_f, b);
1444
1440
}
1441
+
1442
+ void check (const validation_modet vm = validation_modet::INVARIANT) const
1443
+ {
1444
+ DATA_CHECK (!get (ID_width).empty (), " float bitvector type must have width" );
1445
+ }
1445
1446
};
1446
1447
1447
1448
// / Check whether a reference to a typet is a \ref floatbv_typet.
@@ -1453,12 +1454,6 @@ inline bool can_cast_type<floatbv_typet>(const typet &type)
1453
1454
return type.id () == ID_floatbv;
1454
1455
}
1455
1456
1456
- inline void validate_type (const floatbv_typet &type)
1457
- {
1458
- DATA_INVARIANT (
1459
- !type.get (ID_width).empty (), " float bitvector type must have width" );
1460
- }
1461
-
1462
1457
// / \brief Cast a typet to a \ref floatbv_typet
1463
1458
// /
1464
1459
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1471,7 +1466,7 @@ inline const floatbv_typet &to_floatbv_type(const typet &type)
1471
1466
{
1472
1467
PRECONDITION (can_cast_type<floatbv_typet>(type));
1473
1468
const floatbv_typet &ret = static_cast <const floatbv_typet &>(type);
1474
- validate_type ( ret);
1469
+ ret. check ( );
1475
1470
return ret;
1476
1471
}
1477
1472
@@ -1480,7 +1475,7 @@ inline floatbv_typet &to_floatbv_type(typet &type)
1480
1475
{
1481
1476
PRECONDITION (can_cast_type<floatbv_typet>(type));
1482
1477
floatbv_typet &ret = static_cast <floatbv_typet &>(type);
1483
- validate_type ( ret);
1478
+ ret. check ( );
1484
1479
return ret;
1485
1480
}
1486
1481
@@ -1539,6 +1534,11 @@ class pointer_typet:public bitvector_typet
1539
1534
{
1540
1535
return signedbv_typet (get_width ());
1541
1536
}
1537
+
1538
+ void check (const validation_modet vm = validation_modet::INVARIANT) const
1539
+ {
1540
+ DATA_CHECK (!get (ID_width).empty (), " pointer must have width" );
1541
+ }
1542
1542
};
1543
1543
1544
1544
// / Check whether a reference to a typet is a \ref pointer_typet.
@@ -1550,11 +1550,6 @@ inline bool can_cast_type<pointer_typet>(const typet &type)
1550
1550
return type.id () == ID_pointer;
1551
1551
}
1552
1552
1553
- inline void validate_type (const pointer_typet &type)
1554
- {
1555
- DATA_INVARIANT (!type.get (ID_width).empty (), " pointer must have width" );
1556
- }
1557
-
1558
1553
// / \brief Cast a typet to a \ref pointer_typet
1559
1554
// /
1560
1555
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1567,7 +1562,7 @@ inline const pointer_typet &to_pointer_type(const typet &type)
1567
1562
{
1568
1563
PRECONDITION (can_cast_type<pointer_typet>(type));
1569
1564
const pointer_typet &ret = static_cast <const pointer_typet &>(type);
1570
- validate_type ( ret);
1565
+ ret. check ( );
1571
1566
return ret;
1572
1567
}
1573
1568
@@ -1576,7 +1571,7 @@ inline pointer_typet &to_pointer_type(typet &type)
1576
1571
{
1577
1572
PRECONDITION (can_cast_type<pointer_typet>(type));
1578
1573
pointer_typet &ret = static_cast <pointer_typet &>(type);
1579
- validate_type ( ret);
1574
+ ret. check ( );
1580
1575
return ret;
1581
1576
}
1582
1577
@@ -1641,6 +1636,11 @@ class c_bool_typet:public bitvector_typet
1641
1636
bitvector_typet(ID_c_bool, width)
1642
1637
{
1643
1638
}
1639
+
1640
+ void check (const validation_modet vm = validation_modet::INVARIANT) const
1641
+ {
1642
+ DATA_CHECK (!get (ID_width).empty (), " C bool type must have width" );
1643
+ }
1644
1644
};
1645
1645
1646
1646
// / Check whether a reference to a typet is a \ref c_bool_typet.
@@ -1652,11 +1652,6 @@ inline bool can_cast_type<c_bool_typet>(const typet &type)
1652
1652
return type.id () == ID_c_bool;
1653
1653
}
1654
1654
1655
- inline void validate_type (const c_bool_typet &type)
1656
- {
1657
- DATA_INVARIANT (!type.get (ID_width).empty (), " C bool type must have width" );
1658
- }
1659
-
1660
1655
// / \brief Cast a typet to a \ref c_bool_typet
1661
1656
// /
1662
1657
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1669,7 +1664,7 @@ inline const c_bool_typet &to_c_bool_type(const typet &type)
1669
1664
{
1670
1665
PRECONDITION (can_cast_type<c_bool_typet>(type));
1671
1666
const c_bool_typet &ret = static_cast <const c_bool_typet &>(type);
1672
- validate_type ( ret);
1667
+ ret. check ( );
1673
1668
return ret;
1674
1669
}
1675
1670
@@ -1678,7 +1673,7 @@ inline c_bool_typet &to_c_bool_type(typet &type)
1678
1673
{
1679
1674
PRECONDITION (can_cast_type<c_bool_typet>(type));
1680
1675
c_bool_typet &ret = static_cast <c_bool_typet &>(type);
1681
- validate_type ( ret);
1676
+ ret. check ( );
1682
1677
return ret;
1683
1678
}
1684
1679
0 commit comments