@@ -968,15 +968,15 @@ inline bool can_cast_type<code_typet>(const typet &type)
968
968
inline const code_typet &to_code_type (const typet &type)
969
969
{
970
970
PRECONDITION (can_cast_type<code_typet>(type));
971
- validate_type (type);
971
+ code_typet::check (type);
972
972
return static_cast <const code_typet &>(type);
973
973
}
974
974
975
975
// / \copydoc to_code_type(const typet &)
976
976
inline code_typet &to_code_type (typet &type)
977
977
{
978
978
PRECONDITION (can_cast_type<code_typet>(type));
979
- validate_type (type);
979
+ code_typet::check (type);
980
980
return static_cast <code_typet &>(type);
981
981
}
982
982
@@ -1125,6 +1125,13 @@ class bv_typet:public bitvector_typet
1125
1125
{
1126
1126
set_width (width);
1127
1127
}
1128
+
1129
+ static void check (
1130
+ const typet &type,
1131
+ const validation_modet vm = validation_modet::INVARIANT)
1132
+ {
1133
+ DATA_CHECK (!type.get (ID_width).empty (), " bitvector type must have width" );
1134
+ }
1128
1135
};
1129
1136
1130
1137
// / Check whether a reference to a typet is a \ref bv_typet.
@@ -1136,11 +1143,6 @@ inline bool can_cast_type<bv_typet>(const typet &type)
1136
1143
return type.id () == ID_bv;
1137
1144
}
1138
1145
1139
- inline void validate_type (const bv_typet &type)
1140
- {
1141
- DATA_INVARIANT (!type.get (ID_width).empty (), " bitvector type must have width" );
1142
- }
1143
-
1144
1146
// / \brief Cast a typet to a \ref bv_typet
1145
1147
// /
1146
1148
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1152,18 +1154,16 @@ inline void validate_type(const bv_typet &type)
1152
1154
inline const bv_typet &to_bv_type (const typet &type)
1153
1155
{
1154
1156
PRECONDITION (can_cast_type<bv_typet>(type));
1155
- const bv_typet &ret = static_cast <const bv_typet &>(type);
1156
- validate_type (ret);
1157
- return ret;
1157
+ bv_typet::check (type);
1158
+ return static_cast <const bv_typet &>(type);
1158
1159
}
1159
1160
1160
1161
// / \copydoc to_bv_type(const typet &)
1161
1162
inline bv_typet &to_bv_type (typet &type)
1162
1163
{
1163
1164
PRECONDITION (can_cast_type<bv_typet>(type));
1164
- bv_typet &ret = static_cast <bv_typet &>(type);
1165
- validate_type (ret);
1166
- return ret;
1165
+ bv_typet::check (type);
1166
+ return static_cast <bv_typet &>(type);
1167
1167
}
1168
1168
1169
1169
// / Fixed-width bit-vector with unsigned binary interpretation
@@ -1235,6 +1235,14 @@ class signedbv_typet:public bitvector_typet
1235
1235
constant_exprt smallest_expr () const ;
1236
1236
constant_exprt zero_expr () const ;
1237
1237
constant_exprt largest_expr () const ;
1238
+
1239
+ static void check (
1240
+ const typet &type,
1241
+ const validation_modet vm = validation_modet::INVARIANT)
1242
+ {
1243
+ DATA_CHECK (
1244
+ !type.get (ID_width).empty (), " signed bitvector type must have width" );
1245
+ }
1238
1246
};
1239
1247
1240
1248
// / Check whether a reference to a typet is a \ref signedbv_typet.
@@ -1246,12 +1254,6 @@ inline bool can_cast_type<signedbv_typet>(const typet &type)
1246
1254
return type.id () == ID_signedbv;
1247
1255
}
1248
1256
1249
- inline void validate_type (const signedbv_typet &type)
1250
- {
1251
- DATA_INVARIANT (
1252
- !type.get (ID_width).empty (), " signed bitvector type must have width" );
1253
- }
1254
-
1255
1257
// / \brief Cast a typet to a \ref signedbv_typet
1256
1258
// /
1257
1259
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1263,18 +1265,16 @@ inline void validate_type(const signedbv_typet &type)
1263
1265
inline const signedbv_typet &to_signedbv_type (const typet &type)
1264
1266
{
1265
1267
PRECONDITION (can_cast_type<signedbv_typet>(type));
1266
- const signedbv_typet &ret = static_cast <const signedbv_typet &>(type);
1267
- validate_type (ret);
1268
- return ret;
1268
+ signedbv_typet::check (type);
1269
+ return static_cast <const signedbv_typet &>(type);
1269
1270
}
1270
1271
1271
1272
// / \copydoc to_signedbv_type(const typet &)
1272
1273
inline signedbv_typet &to_signedbv_type (typet &type)
1273
1274
{
1274
1275
PRECONDITION (can_cast_type<signedbv_typet>(type));
1275
- signedbv_typet &ret = static_cast <signedbv_typet &>(type);
1276
- validate_type (ret);
1277
- return ret;
1276
+ signedbv_typet::check (type);
1277
+ return static_cast <signedbv_typet &>(type);
1278
1278
}
1279
1279
1280
1280
// / Fixed-width bit-vector with signed fixed-point interpretation
@@ -1299,6 +1299,14 @@ class fixedbv_typet:public bitvector_typet
1299
1299
{
1300
1300
set (ID_integer_bits, narrow_cast<long long >(b));
1301
1301
}
1302
+
1303
+ static void check (
1304
+ const typet &type,
1305
+ const validation_modet vm = validation_modet::INVARIANT)
1306
+ {
1307
+ DATA_CHECK (
1308
+ !type.get (ID_width).empty (), " fixed bitvector type must have width" );
1309
+ }
1302
1310
};
1303
1311
1304
1312
// / Check whether a reference to a typet is a \ref fixedbv_typet.
@@ -1310,12 +1318,6 @@ inline bool can_cast_type<fixedbv_typet>(const typet &type)
1310
1318
return type.id () == ID_fixedbv;
1311
1319
}
1312
1320
1313
- inline void validate_type (const fixedbv_typet &type)
1314
- {
1315
- DATA_INVARIANT (
1316
- !type.get (ID_width).empty (), " fixed bitvector type must have width" );
1317
- }
1318
-
1319
1321
// / \brief Cast a typet to a \ref fixedbv_typet
1320
1322
// /
1321
1323
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1327,18 +1329,16 @@ inline void validate_type(const fixedbv_typet &type)
1327
1329
inline const fixedbv_typet &to_fixedbv_type (const typet &type)
1328
1330
{
1329
1331
PRECONDITION (can_cast_type<fixedbv_typet>(type));
1330
- const fixedbv_typet &ret = static_cast <const fixedbv_typet &>(type);
1331
- validate_type (ret);
1332
- return ret;
1332
+ fixedbv_typet::check (type);
1333
+ return static_cast <const fixedbv_typet &>(type);
1333
1334
}
1334
1335
1335
1336
// / \copydoc to_fixedbv_type(const typet &)
1336
1337
inline fixedbv_typet &to_fixedbv_type (typet &type)
1337
1338
{
1338
1339
PRECONDITION (can_cast_type<fixedbv_typet>(type));
1339
- fixedbv_typet &ret = static_cast <fixedbv_typet &>(type);
1340
- validate_type (ret);
1341
- return ret;
1340
+ fixedbv_typet::check (type);
1341
+ return static_cast <fixedbv_typet &>(type);
1342
1342
}
1343
1343
1344
1344
// / Fixed-width bit-vector with IEEE floating-point interpretation
@@ -1361,6 +1361,14 @@ class floatbv_typet:public bitvector_typet
1361
1361
{
1362
1362
set (ID_f, narrow_cast<long long >(b));
1363
1363
}
1364
+
1365
+ static void check (
1366
+ const typet &type,
1367
+ const validation_modet vm = validation_modet::INVARIANT)
1368
+ {
1369
+ DATA_CHECK (
1370
+ !type.get (ID_width).empty (), " float bitvector type must have width" );
1371
+ }
1364
1372
};
1365
1373
1366
1374
// / Check whether a reference to a typet is a \ref floatbv_typet.
@@ -1372,12 +1380,6 @@ inline bool can_cast_type<floatbv_typet>(const typet &type)
1372
1380
return type.id () == ID_floatbv;
1373
1381
}
1374
1382
1375
- inline void validate_type (const floatbv_typet &type)
1376
- {
1377
- DATA_INVARIANT (
1378
- !type.get (ID_width).empty (), " float bitvector type must have width" );
1379
- }
1380
-
1381
1383
// / \brief Cast a typet to a \ref floatbv_typet
1382
1384
// /
1383
1385
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1389,18 +1391,16 @@ inline void validate_type(const floatbv_typet &type)
1389
1391
inline const floatbv_typet &to_floatbv_type (const typet &type)
1390
1392
{
1391
1393
PRECONDITION (can_cast_type<floatbv_typet>(type));
1392
- const floatbv_typet &ret = static_cast <const floatbv_typet &>(type);
1393
- validate_type (ret);
1394
- return ret;
1394
+ floatbv_typet::check (type);
1395
+ return static_cast <const floatbv_typet &>(type);
1395
1396
}
1396
1397
1397
1398
// / \copydoc to_floatbv_type(const typet &)
1398
1399
inline floatbv_typet &to_floatbv_type (typet &type)
1399
1400
{
1400
1401
PRECONDITION (can_cast_type<floatbv_typet>(type));
1401
- floatbv_typet &ret = static_cast <floatbv_typet &>(type);
1402
- validate_type (ret);
1403
- return ret;
1402
+ floatbv_typet::check (type);
1403
+ return static_cast <floatbv_typet &>(type);
1404
1404
}
1405
1405
1406
1406
// / Type for C bit fields
@@ -1464,6 +1464,13 @@ class pointer_typet:public bitvector_typet
1464
1464
{
1465
1465
return signedbv_typet (get_width ());
1466
1466
}
1467
+
1468
+ static void check (
1469
+ const typet &type,
1470
+ const validation_modet vm = validation_modet::INVARIANT)
1471
+ {
1472
+ DATA_CHECK (!type.get (ID_width).empty (), " pointer must have width" );
1473
+ }
1467
1474
};
1468
1475
1469
1476
// / Check whether a reference to a typet is a \ref pointer_typet.
@@ -1475,11 +1482,6 @@ inline bool can_cast_type<pointer_typet>(const typet &type)
1475
1482
return type.id () == ID_pointer;
1476
1483
}
1477
1484
1478
- inline void validate_type (const pointer_typet &type)
1479
- {
1480
- DATA_INVARIANT (!type.get (ID_width).empty (), " pointer must have width" );
1481
- }
1482
-
1483
1485
// / \brief Cast a typet to a \ref pointer_typet
1484
1486
// /
1485
1487
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1491,18 +1493,16 @@ inline void validate_type(const pointer_typet &type)
1491
1493
inline const pointer_typet &to_pointer_type (const typet &type)
1492
1494
{
1493
1495
PRECONDITION (can_cast_type<pointer_typet>(type));
1494
- const pointer_typet &ret = static_cast <const pointer_typet &>(type);
1495
- validate_type (ret);
1496
- return ret;
1496
+ pointer_typet::check (type);
1497
+ return static_cast <const pointer_typet &>(type);
1497
1498
}
1498
1499
1499
1500
// / \copydoc to_pointer_type(const typet &)
1500
1501
inline pointer_typet &to_pointer_type (typet &type)
1501
1502
{
1502
1503
PRECONDITION (can_cast_type<pointer_typet>(type));
1503
- pointer_typet &ret = static_cast <pointer_typet &>(type);
1504
- validate_type (ret);
1505
- return ret;
1504
+ pointer_typet::check (type);
1505
+ return static_cast <pointer_typet &>(type);
1506
1506
}
1507
1507
1508
1508
// / The reference type
@@ -1562,6 +1562,13 @@ class c_bool_typet:public bitvector_typet
1562
1562
bitvector_typet(ID_c_bool, width)
1563
1563
{
1564
1564
}
1565
+
1566
+ static void check (
1567
+ const typet &type,
1568
+ const validation_modet vm = validation_modet::INVARIANT)
1569
+ {
1570
+ DATA_CHECK (!type.get (ID_width).empty (), " C bool type must have width" );
1571
+ }
1565
1572
};
1566
1573
1567
1574
// / Check whether a reference to a typet is a \ref c_bool_typet.
@@ -1573,11 +1580,6 @@ inline bool can_cast_type<c_bool_typet>(const typet &type)
1573
1580
return type.id () == ID_c_bool;
1574
1581
}
1575
1582
1576
- inline void validate_type (const c_bool_typet &type)
1577
- {
1578
- DATA_INVARIANT (!type.get (ID_width).empty (), " C bool type must have width" );
1579
- }
1580
-
1581
1583
// / \brief Cast a typet to a \ref c_bool_typet
1582
1584
// /
1583
1585
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1589,18 +1591,16 @@ inline void validate_type(const c_bool_typet &type)
1589
1591
inline const c_bool_typet &to_c_bool_type (const typet &type)
1590
1592
{
1591
1593
PRECONDITION (can_cast_type<c_bool_typet>(type));
1592
- const c_bool_typet &ret = static_cast <const c_bool_typet &>(type);
1593
- validate_type (ret);
1594
- return ret;
1594
+ c_bool_typet::check (type);
1595
+ return static_cast <const c_bool_typet &>(type);
1595
1596
}
1596
1597
1597
1598
// / \copydoc to_c_bool_type(const typet &)
1598
1599
inline c_bool_typet &to_c_bool_type (typet &type)
1599
1600
{
1600
1601
PRECONDITION (can_cast_type<c_bool_typet>(type));
1601
- c_bool_typet &ret = static_cast <c_bool_typet &>(type);
1602
- validate_type (ret);
1603
- return ret;
1602
+ c_bool_typet::check (type);
1603
+ return static_cast <c_bool_typet &>(type);
1604
1604
}
1605
1605
1606
1606
// / String type
0 commit comments