Skip to content

Commit f77b843

Browse files
author
martin
committed
Add conversion functions for ID_bitnot.
1 parent 0560b33 commit f77b843

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/util/std_expr.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,36 @@ class bitnot_exprt:public unary_exprt
20522052
}
20532053
};
20542054

2055+
/*! \brief Cast a generic exprt to a \ref bitnot_exprt
2056+
*
2057+
* This is an unchecked conversion. \a expr must be known to be \ref
2058+
* bitnot_exprt.
2059+
*
2060+
* \param expr Source expression
2061+
* \return Object of type \ref bitnot_exprt
2062+
*
2063+
* \ingroup gr_std_expr
2064+
*/
2065+
inline const bitnot_exprt &to_bitnot_expr(const exprt &expr)
2066+
{
2067+
PRECONDITION(expr.id()==ID_bitnot);
2068+
// DATA_INVARIANT(expr.operands().size()==1,
2069+
// "Bit-wise not must have one operand");
2070+
return static_cast<const bitnot_exprt &>(expr);
2071+
}
2072+
2073+
/*! \copydoc to_bitnot_expr(const exprt &)
2074+
* \ingroup gr_std_expr
2075+
*/
2076+
inline bitnot_exprt &to_bitnot_expr(exprt &expr)
2077+
{
2078+
PRECONDITION(expr.id()==ID_bitnot);
2079+
// DATA_INVARIANT(expr.operands().size()==1,
2080+
// "Bit-wise not must have one operand");
2081+
return static_cast<bitnot_exprt &>(expr);
2082+
}
2083+
2084+
20552085
/*! \brief Bit-wise OR
20562086
*/
20572087
class bitor_exprt:public multi_ary_exprt

0 commit comments

Comments
 (0)