File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -892,6 +892,44 @@ inline void validate_expr(const unary_overflow_exprt &value)
892892 value, 1 , " unary overflow expression must have one operand" );
893893}
894894
895+ // / \brief A Boolean expression returning true, iff negation would result in an
896+ // / overflow when applied to the (single) operand.
897+ class unary_minus_overflow_exprt : public unary_overflow_exprt
898+ {
899+ public:
900+ explicit unary_minus_overflow_exprt (exprt _op)
901+ : unary_overflow_exprt(ID_unary_minus, std::move(_op))
902+ {
903+ }
904+
905+ static void check (
906+ const exprt &expr,
907+ const validation_modet vm = validation_modet::INVARIANT)
908+ {
909+ unary_exprt::check (expr, vm);
910+ }
911+
912+ static void validate (
913+ const exprt &expr,
914+ const namespacet &,
915+ const validation_modet vm = validation_modet::INVARIANT)
916+ {
917+ check (expr, vm);
918+ }
919+ };
920+
921+ template <>
922+ inline bool can_cast_expr<unary_minus_overflow_exprt>(const exprt &base)
923+ {
924+ return base.id () == ID_overflow_unary_minus;
925+ }
926+
927+ inline void validate_expr (const unary_minus_overflow_exprt &value)
928+ {
929+ validate_operands (
930+ value, 1 , " unary minus overflow expression must have one operand" );
931+ }
932+
895933// / \brief Cast an exprt to a \ref unary_overflow_exprt
896934// /
897935// / \a expr must be known to be \ref unary_overflow_exprt.
You can’t perform that action at this time.
0 commit comments