Skip to content

Commit 0310a02

Browse files
authored
Merge pull request #4183 from smowton/smowton/cleanup/simplify-object-descriptor
Simplify and avoid redundant typecasts in build_object_descriptor
2 parents 02ce47f + 7d0ce45 commit 0310a02

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

jbmc/unit/java_bytecode/goto_program_generics/generic_bases_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ SCENARIO(
2121
"Instantiate generic parameters of superclasses",
2222
"[core][goto_program_generics][generic_bases_test]")
2323
{
24+
config.ansi_c.set_LP64();
25+
2426
GIVEN(
2527
"A class extending a generic class instantiated with a standard library "
2628
"class")

src/goto-symex/symex_clean_expr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ process_array_expr(exprt &expr, bool do_simplify, const namespacet &ns)
7272
{
7373
object_descriptor_exprt ode;
7474
ode.build(expr, ns);
75-
if(do_simplify)
76-
simplify(ode.offset(), ns);
7775

7876
expr = ode.root_object();
7977

src/util/std_expr.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include "expr_util.h"
1717
#include "mathematical_types.h"
1818
#include "pointer_offset_size.h"
19+
#include "simplify_expr.h"
1920

2021
bool constant_exprt::value_is_zero_string() const
2122
{
@@ -72,10 +73,11 @@ static void build_object_descriptor_rec(
7273
exprt sub_size=size_of_expr(expr.type(), ns);
7374
CHECK_RETURN(sub_size.is_not_nil());
7475

75-
dest.offset()=
76-
plus_exprt(dest.offset(),
77-
mult_exprt(typecast_exprt(index.index(), index_type()),
78-
typecast_exprt(sub_size, index_type())));
76+
dest.offset() = plus_exprt(
77+
dest.offset(),
78+
mult_exprt(
79+
typecast_exprt::conditional_cast(index.index(), index_type()),
80+
typecast_exprt::conditional_cast(sub_size, index_type())));
7981
}
8082
else if(expr.id()==ID_member)
8183
{
@@ -87,9 +89,8 @@ static void build_object_descriptor_rec(
8789
exprt offset=member_offset_expr(member, ns);
8890
CHECK_RETURN(offset.is_not_nil());
8991

90-
dest.offset()=
91-
plus_exprt(dest.offset(),
92-
typecast_exprt(offset, index_type()));
92+
dest.offset() = plus_exprt(
93+
dest.offset(), typecast_exprt::conditional_cast(offset, index_type()));
9394
}
9495
else if(expr.id()==ID_byte_extract_little_endian ||
9596
expr.id()==ID_byte_extract_big_endian)
@@ -100,10 +101,10 @@ static void build_object_descriptor_rec(
100101

101102
build_object_descriptor_rec(ns, be.op(), dest);
102103

103-
dest.offset()=
104-
plus_exprt(dest.offset(),
105-
typecast_exprt(to_byte_extract_expr(expr).offset(),
106-
index_type()));
104+
dest.offset() = plus_exprt(
105+
dest.offset(),
106+
typecast_exprt::conditional_cast(
107+
to_byte_extract_expr(expr).offset(), index_type()));
107108
}
108109
else if(expr.id()==ID_typecast)
109110
{
@@ -145,6 +146,7 @@ void object_descriptor_exprt::build(
145146
offset()=from_integer(0, index_type());
146147

147148
build_object_descriptor_rec(ns, expr, *this);
149+
simplify(offset(), ns);
148150
}
149151

150152
shift_exprt::shift_exprt(

0 commit comments

Comments
 (0)