Skip to content

Commit 78aa8a0

Browse files
committed
add to_object_size_expr
1 parent 497f06f commit 78aa8a0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/util/pointer_expr.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,29 @@ class object_size_exprt : public unary_exprt
10221022
}
10231023
};
10241024

1025+
/// \brief Cast an exprt to a \ref object_size_exprt
1026+
///
1027+
/// \a expr must be known to be \ref object_size_exprt.
1028+
///
1029+
/// \param expr: Source expression
1030+
/// \return Object of type \ref object_size_exprt
1031+
inline const object_size_exprt &to_object_size_expr(const exprt &expr)
1032+
{
1033+
PRECONDITION(expr.id() == ID_object_size);
1034+
const object_size_exprt &ret = static_cast<const object_size_exprt &>(expr);
1035+
validate_expr(ret);
1036+
return ret;
1037+
}
1038+
1039+
/// \copydoc to_object_size_expr(const exprt &)
1040+
inline object_size_exprt &to_object_size_expr(exprt &expr)
1041+
{
1042+
PRECONDITION(expr.id() == ID_object_size);
1043+
object_size_exprt &ret = static_cast<object_size_exprt &>(expr);
1044+
validate_expr(ret);
1045+
return ret;
1046+
}
1047+
10251048
template <>
10261049
inline bool can_cast_expr<object_size_exprt>(const exprt &base)
10271050
{

0 commit comments

Comments
 (0)