Skip to content

Commit 21069eb

Browse files
committed
Move has_byte_operator to util
There is nothing solvers-specific to this function. Cleanup in preparation of moving all byte-operator lowering to util.
1 parent 1199c56 commit 21069eb

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/solvers/lowering/byte_operators.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,21 +2483,6 @@ exprt lower_byte_update(const byte_update_exprt &src, const namespacet &ns)
24832483
return result;
24842484
}
24852485

2486-
bool has_byte_operator(const exprt &src)
2487-
{
2488-
if(src.id()==ID_byte_update_little_endian ||
2489-
src.id()==ID_byte_update_big_endian ||
2490-
src.id()==ID_byte_extract_little_endian ||
2491-
src.id()==ID_byte_extract_big_endian)
2492-
return true;
2493-
2494-
forall_operands(it, src)
2495-
if(has_byte_operator(*it))
2496-
return true;
2497-
2498-
return false;
2499-
}
2500-
25012486
exprt lower_byte_operators(const exprt &src, const namespacet &ns)
25022487
{
25032488
exprt tmp=src;

src/solvers/lowering/expr_lowering.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,4 @@ exprt lower_byte_update(const byte_update_exprt &src, const namespacet &ns);
4141
/// byte_extract_exprt or \ref byte_update_exprt.
4242
exprt lower_byte_operators(const exprt &src, const namespacet &ns);
4343

44-
bool has_byte_operator(const exprt &src);
45-
4644
#endif /* CPROVER_SOLVERS_LOWERING_EXPR_LOWERING_H */

src/util/byte_operators.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,18 @@ make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value)
5757
return byte_update_exprt{
5858
byte_update_id(), _op, _offset, _value, config.ansi_c.char_width};
5959
}
60+
61+
bool has_byte_operator(const exprt &src)
62+
{
63+
if(src.id()==ID_byte_update_little_endian ||
64+
src.id()==ID_byte_update_big_endian ||
65+
src.id()==ID_byte_extract_little_endian ||
66+
src.id()==ID_byte_extract_big_endian)
67+
return true;
68+
69+
forall_operands(it, src)
70+
if(has_byte_operator(*it))
71+
return true;
72+
73+
return false;
74+
}

src/util/byte_operators.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,8 @@ make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type);
162162
byte_update_exprt
163163
make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value);
164164

165+
/// Return true iff \p src or one of its operands contain a byte extract or byte
166+
/// update expression.
167+
bool has_byte_operator(const exprt &src);
168+
165169
#endif // CPROVER_UTIL_BYTE_OPERATORS_H

0 commit comments

Comments
 (0)