Skip to content

Commit a588dd4

Browse files
committed
Do not use back-end pointer encoding details in the simplifier
The object:offset encoding is an implementation detail that should be private to the back-end. Expression simplification must not rely on such details. Partly reverts 4d35274.
1 parent a660a60 commit a588dd4

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

src/util/simplify_expr_pointer.cpp

-18
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include "arith_tools.h"
1212
#include "c_types.h"
13-
#include "config.h"
1413
#include "expr_util.h"
1514
#include "namespace.h"
1615
#include "pointer_expr.h"
@@ -400,23 +399,6 @@ simplify_exprt::simplify_pointer_offset(const pointer_offset_exprt &expr)
400399
{
401400
return from_integer(0, expr.type());
402401
}
403-
else
404-
{
405-
// this is a pointer, we can't use to_integer
406-
const auto width = to_pointer_type(ptr.type()).get_width();
407-
mp_integer number = bvrep2integer(c_ptr.get_value(), width, false);
408-
// a null pointer would have been caught above, return value 0
409-
// will indicate that conversion failed
410-
if(number==0)
411-
return unchanged(expr);
412-
413-
// The constant address consists of OBJECT-ID || OFFSET.
414-
mp_integer offset_bits =
415-
*pointer_offset_bits(ptr.type(), ns) - config.bv_encoding.object_bits;
416-
number%=power(2, offset_bits);
417-
418-
return from_integer(number, expr.type());
419-
}
420402
}
421403

422404
return unchanged(expr);

unit/util/simplify_expr.cpp

-21
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,6 @@ TEST_CASE("Simplify pointer_offset(address of array index)", "[core][util]")
4444
REQUIRE(offset_value==1);
4545
}
4646

47-
TEST_CASE("Simplify const pointer offset", "[core][util]")
48-
{
49-
config.set_arch("none");
50-
51-
symbol_tablet symbol_table;
52-
namespacet ns(symbol_table);
53-
54-
// build a numeric constant of some pointer type
55-
constant_exprt number=from_integer(1234, size_type());
56-
number.type()=pointer_type(char_type());
57-
58-
exprt p_o=pointer_offset(number);
59-
60-
exprt simp=simplify_expr(p_o, ns);
61-
62-
REQUIRE(simp.is_constant());
63-
const mp_integer offset_value =
64-
numeric_cast_v<mp_integer>(to_constant_expr(simp));
65-
REQUIRE(offset_value==1234);
66-
}
67-
6847
TEST_CASE("Simplify byte extract", "[core][util]")
6948
{
7049
// this test does require a proper architecture to be set so that byte extract

0 commit comments

Comments
 (0)