File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed
regression/cbmc-java/json_trace1 Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 1+ public class Test {
2+
3+ byte main (byte [] a ) {
4+ if (a .length != 9 ) {
5+ return -1 ;
6+ }
7+
8+ byte diff = 0 ;
9+ for (byte i = 0 ; i < 9 ; i ++) {
10+ if (a [i ] == 1 ) {
11+ diff ++;
12+ } else if (a [i ] == 2 ) {
13+ diff --;
14+ } else if (a [i ] != 0 ) {
15+ return -1 ;
16+ }
17+ }
18+
19+ return -1 ;
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ Test.class
3+ --cover location --trace --json-ui
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ --
7+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ Author: Daniel Kroening
1717#include < util/arith_tools.h>
1818
1919#include < langapi/language_util.h>
20+ #include < solvers/flattening/pointer_logic.h>
2021
2122#include " json_goto_trace.h"
2223
@@ -25,8 +26,16 @@ Author: Daniel Kroening
2526// / \param src: an expression
2627void remove_pointer_offsets (exprt &src)
2728{
28- if (src.id ()==ID_pointer_offset && src.op0 ().id ()==ID_constant)
29- src=src.op0 ();
29+ if (src.id ()==ID_pointer_offset &&
30+ src.op0 ().id ()==ID_constant &&
31+ src.op0 ().type ().id ()==ID_pointer)
32+ {
33+ std::string binary_str=id2string (to_constant_expr (src.op0 ()).get_value ());
34+ // The constant address consists of OBJECT-ID || OFFSET.
35+ // Shift out the object-identifier bits, leaving only the offset:
36+ mp_integer offset=binary2integer (binary_str.substr (BV_ADDR_BITS), false );
37+ src=from_integer (offset, src.type ());
38+ }
3039 else
3140 for (auto &op : src.operands ())
3241 remove_pointer_offsets (op);
You can’t perform that action at this time.
0 commit comments