Skip to content

Commit 02c7a36

Browse files
committed
r/w/rw_ok: implement can_cast_expr and validate_expr
We should provide these for all expression classes.
1 parent b637952 commit 02c7a36

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/util/pointer_expr.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,17 @@ class r_or_w_ok_exprt : public binary_predicate_exprt
833833
}
834834
};
835835

836+
template <>
837+
inline bool can_cast_expr<r_or_w_ok_exprt>(const exprt &base)
838+
{
839+
return base.id() == ID_r_ok || base.id() == ID_w_ok || base.id() == ID_rw_ok;
840+
}
841+
842+
inline void validate_expr(const r_or_w_ok_exprt &value)
843+
{
844+
validate_operands(value, 2, "r_or_w_ok must have two operands");
845+
}
846+
836847
inline const r_or_w_ok_exprt &to_r_or_w_ok_expr(const exprt &expr)
837848
{
838849
PRECONDITION(
@@ -852,6 +863,17 @@ class r_ok_exprt : public r_or_w_ok_exprt
852863
}
853864
};
854865

866+
template <>
867+
inline bool can_cast_expr<r_ok_exprt>(const exprt &base)
868+
{
869+
return base.id() == ID_r_ok;
870+
}
871+
872+
inline void validate_expr(const r_ok_exprt &value)
873+
{
874+
validate_operands(value, 2, "r_ok must have two operands");
875+
}
876+
855877
inline const r_ok_exprt &to_r_ok_expr(const exprt &expr)
856878
{
857879
PRECONDITION(expr.id() == ID_r_ok);
@@ -870,6 +892,17 @@ class w_ok_exprt : public r_or_w_ok_exprt
870892
}
871893
};
872894

895+
template <>
896+
inline bool can_cast_expr<w_ok_exprt>(const exprt &base)
897+
{
898+
return base.id() == ID_w_ok;
899+
}
900+
901+
inline void validate_expr(const w_ok_exprt &value)
902+
{
903+
validate_operands(value, 2, "w_ok must have two operands");
904+
}
905+
873906
inline const w_ok_exprt &to_w_ok_expr(const exprt &expr)
874907
{
875908
PRECONDITION(expr.id() == ID_w_ok);

0 commit comments

Comments
 (0)