Skip to content

Commit bd95317

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#1753 from diffblue/xor_exprt
added multi-ary xor_exprt
2 parents 1d4af6d + 80dd48a commit bd95317

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/util/std_expr.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,60 @@ template<> inline bool can_cast_expr<or_exprt>(const exprt &base)
23742374
// }
23752375

23762376

2377+
/*! \brief Boolean XOR
2378+
*/
2379+
class xor_exprt:public multi_ary_exprt
2380+
{
2381+
public:
2382+
xor_exprt():multi_ary_exprt(ID_bitxor, bool_typet())
2383+
{
2384+
}
2385+
2386+
xor_exprt(const exprt &_op0, const exprt &_op1):
2387+
multi_ary_exprt(_op0, ID_xor, _op1, bool_typet())
2388+
{
2389+
}
2390+
};
2391+
2392+
/*! \brief Cast a generic exprt to a \ref xor_exprt
2393+
*
2394+
* This is an unchecked conversion. \a expr must be known to be \ref
2395+
* xor_exprt.
2396+
*
2397+
* \param expr Source expression
2398+
* \return Object of type \ref xor_exprt
2399+
*
2400+
* \ingroup gr_std_expr
2401+
*/
2402+
inline const xor_exprt &to_xor_expr(const exprt &expr)
2403+
{
2404+
PRECONDITION(expr.id()==ID_xor);
2405+
return static_cast<const xor_exprt &>(expr);
2406+
}
2407+
2408+
/*! \copydoc to_bitxor_expr(const exprt &)
2409+
* \ingroup gr_std_expr
2410+
*/
2411+
inline xor_exprt &to_xor_expr(exprt &expr)
2412+
{
2413+
PRECONDITION(expr.id()==ID_xor);
2414+
return static_cast<xor_exprt &>(expr);
2415+
}
2416+
2417+
template<> inline bool can_cast_expr<xor_exprt>(const exprt &base)
2418+
{
2419+
return base.id()==ID_xor;
2420+
}
2421+
// inline void validate_expr(const bitxor_exprt &value)
2422+
// {
2423+
// validate_operands(
2424+
// value,
2425+
// 2,
2426+
// "Bit-wise xor must have two or more operands",
2427+
// true);
2428+
// }
2429+
2430+
23772431
/*! \brief Bit-wise negation of bit-vectors
23782432
*/
23792433
class bitnot_exprt:public unary_exprt

0 commit comments

Comments
 (0)