Skip to content

Commit b186e25

Browse files
committed
Flatten byte_{extract,update} when pointers are involved
1 parent 599501c commit b186e25

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/solvers/flattening/boolbv_byte_extract.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111
#include <cassert>
1212

1313
#include <util/arith_tools.h>
14+
#include <util/expr_util.h>
1415
#include <util/std_expr.h>
1516
#include <util/byte_operators.h>
1617

@@ -39,8 +40,11 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
3940
if(expr.operands().size()!=2)
4041
throw "byte_extract takes two operands";
4142

42-
// if we extract from an unbounded array, call the flattening code
43-
if(is_unbounded_array(expr.op().type()))
43+
// if we extract from an unbounded array or a data type that
44+
// includes pointers, call the flattening code
45+
if(is_unbounded_array(expr.op().type()) ||
46+
has_subtype(expr.type(), ID_pointer, ns) ||
47+
has_subtype(expr.op().type(), ID_pointer, ns))
4448
{
4549
exprt tmp=flatten_byte_extract(expr, ns);
4650
return convert_bv(tmp);

src/solvers/flattening/boolbv_byte_update.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,30 @@ Author: Daniel Kroening, [email protected]
88

99
#include "boolbv.h"
1010

11-
#include <iostream>
1211
#include <cassert>
1312

1413
#include <util/arith_tools.h>
1514
#include <util/byte_operators.h>
15+
#include <util/expr_util.h>
1616

1717
#include "bv_endianness_map.h"
18+
#include "flatten_byte_operators.h"
1819

1920
bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
2021
{
2122
if(expr.operands().size()!=3)
2223
throw "byte_update takes three operands";
2324

25+
// if we update an unbounded array or a data type that
26+
// includes pointers, call the flattening code
27+
if(is_unbounded_array(expr.op().type()) ||
28+
has_subtype(expr.value().type(), ID_pointer, ns) ||
29+
has_subtype(expr.op0().type(), ID_pointer, ns))
30+
{
31+
exprt tmp=flatten_byte_update(expr, ns);
32+
return convert_bv(tmp);
33+
}
34+
2435
const exprt &op=expr.op0();
2536
const exprt &offset_expr=expr.offset();
2637
const exprt &value=expr.value();

0 commit comments

Comments
 (0)