Skip to content

Commit 63703d2

Browse files
authored
Merge pull request #7461 from tautschnig/cleanup/rw_ok-cast
r/w/rw_ok: implement can_cast_expr and validate_expr
2 parents 1d5a075 + 2e4a1df commit 63703d2

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
@@ -818,6 +818,17 @@ class r_or_w_ok_exprt : public binary_predicate_exprt
818818
}
819819
};
820820

821+
template <>
822+
inline bool can_cast_expr<r_or_w_ok_exprt>(const exprt &base)
823+
{
824+
return base.id() == ID_r_ok || base.id() == ID_w_ok || base.id() == ID_rw_ok;
825+
}
826+
827+
inline void validate_expr(const r_or_w_ok_exprt &value)
828+
{
829+
validate_operands(value, 2, "r_or_w_ok must have two operands");
830+
}
831+
821832
inline const r_or_w_ok_exprt &to_r_or_w_ok_expr(const exprt &expr)
822833
{
823834
PRECONDITION(
@@ -837,6 +848,17 @@ class r_ok_exprt : public r_or_w_ok_exprt
837848
}
838849
};
839850

851+
template <>
852+
inline bool can_cast_expr<r_ok_exprt>(const exprt &base)
853+
{
854+
return base.id() == ID_r_ok;
855+
}
856+
857+
inline void validate_expr(const r_ok_exprt &value)
858+
{
859+
validate_operands(value, 2, "r_ok must have two operands");
860+
}
861+
840862
inline const r_ok_exprt &to_r_ok_expr(const exprt &expr)
841863
{
842864
PRECONDITION(expr.id() == ID_r_ok);
@@ -855,6 +877,17 @@ class w_ok_exprt : public r_or_w_ok_exprt
855877
}
856878
};
857879

880+
template <>
881+
inline bool can_cast_expr<w_ok_exprt>(const exprt &base)
882+
{
883+
return base.id() == ID_w_ok;
884+
}
885+
886+
inline void validate_expr(const w_ok_exprt &value)
887+
{
888+
validate_operands(value, 2, "w_ok must have two operands");
889+
}
890+
858891
inline const w_ok_exprt &to_w_ok_expr(const exprt &expr)
859892
{
860893
PRECONDITION(expr.id() == ID_w_ok);

0 commit comments

Comments
 (0)