Skip to content

Commit 1d55b7b

Browse files
danpoePetr Bauch
authored and
Petr Bauch
committed
Add and use validation methods in unsignedbv_typet
1 parent a9a8535 commit 1d55b7b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/util/std_types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,12 @@ class unsignedbv_typet:public bitvector_typet
12451245
constant_exprt smallest_expr() const;
12461246
constant_exprt zero_expr() const;
12471247
constant_exprt largest_expr() const;
1248+
1249+
void check(const validation_modet vm = validation_modet::INVARIANT) const
1250+
{
1251+
DATA_CHECK(
1252+
!get(ID_width).empty(), "unsigned bitvector type must have width");
1253+
}
12481254
};
12491255

12501256
/// Check whether a reference to a typet is a \ref unsignedbv_typet.
@@ -1256,12 +1262,6 @@ inline bool can_cast_type<unsignedbv_typet>(const typet &type)
12561262
return type.id() == ID_unsignedbv;
12571263
}
12581264

1259-
inline void validate_type(const unsignedbv_typet &type)
1260-
{
1261-
DATA_INVARIANT(
1262-
!type.get(ID_width).empty(), "unsigned bitvector type must have width");
1263-
}
1264-
12651265
/// \brief Cast a typet to an \ref unsignedbv_typet
12661266
///
12671267
/// This is an unchecked conversion. \a type must be known to be \ref
@@ -1274,7 +1274,7 @@ inline const unsignedbv_typet &to_unsignedbv_type(const typet &type)
12741274
{
12751275
PRECONDITION(can_cast_type<unsignedbv_typet>(type));
12761276
const unsignedbv_typet &ret = static_cast<const unsignedbv_typet &>(type);
1277-
validate_type(ret);
1277+
ret.check();
12781278
return ret;
12791279
}
12801280

@@ -1283,7 +1283,7 @@ inline unsignedbv_typet &to_unsignedbv_type(typet &type)
12831283
{
12841284
PRECONDITION(can_cast_type<unsignedbv_typet>(type));
12851285
unsignedbv_typet &ret = static_cast<unsignedbv_typet &>(type);
1286-
validate_type(ret);
1286+
ret.check();
12871287
return ret;
12881288
}
12891289

0 commit comments

Comments
 (0)