Skip to content

Commit 27b02b3

Browse files
authored
Merge pull request #6544 from tautschnig/remove-look_through_casts
Remove and replace use of look_through_casts
2 parents b79bd51 + 51c133c commit 27b02b3

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

jbmc/src/java_bytecode/java_pointer_casts.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "java_pointer_casts.h"
1313

14+
#include <util/expr_util.h>
1415
#include <util/namespace.h>
1516
#include <util/pointer_expr.h>
1617
#include <util/std_expr.h>
@@ -64,21 +65,6 @@ bool find_superclass_with_type(
6465
}
6566
}
6667

67-
68-
/// \par parameters: input expression
69-
/// \return recursively search target of typecast
70-
static const exprt &look_through_casts(const exprt &in)
71-
{
72-
if(in.id()==ID_typecast)
73-
{
74-
assert(in.type().id()==ID_pointer);
75-
return look_through_casts(to_typecast_expr(in).op());
76-
}
77-
else
78-
return in;
79-
}
80-
81-
8268
/// \par parameters: raw pointer
8369
/// target type
8470
/// namespace
@@ -88,7 +74,7 @@ exprt make_clean_pointer_cast(
8874
const pointer_typet &target_type,
8975
const namespacet &ns)
9076
{
91-
const exprt &ptr=look_through_casts(rawptr);
77+
const exprt &ptr = skip_typecast(rawptr);
9278

9379
PRECONDITION(ptr.type().id()==ID_pointer);
9480

src/analyses/variable-sensitivity/interval_abstract_value.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <util/arith_tools.h>
1212
#include <util/bitvector_types.h>
13+
#include <util/expr_util.h>
1314
#include <util/invariant.h>
1415
#include <util/make_unique.h>
1516
#include <util/simplify_expr.h>
@@ -74,15 +75,6 @@ static index_range_implementation_ptrt make_interval_index_range(
7475
return util_make_unique<interval_index_ranget>(interval, n);
7576
}
7677

77-
static inline exprt look_through_casts(exprt e)
78-
{
79-
while(e.id() == ID_typecast)
80-
{
81-
e = to_typecast_expr(e).op();
82-
}
83-
return e;
84-
}
85-
8678
static inline bool
8779
bvint_value_is_max(const typet &type, const mp_integer &value)
8880
{
@@ -153,15 +145,16 @@ interval_from_x_gt_value(const exprt &value)
153145
return constant_interval_exprt::bottom(value.type());
154146
}
155147

156-
static inline bool represents_interval(exprt e)
148+
static inline bool represents_interval(const exprt &expr)
157149
{
158-
e = look_through_casts(e);
150+
const exprt &e = skip_typecast(expr);
159151
return (e.id() == ID_constant_interval || e.id() == ID_constant);
160152
}
161153

162-
static inline constant_interval_exprt make_interval_expr(exprt e)
154+
static inline constant_interval_exprt make_interval_expr(const exprt &expr)
163155
{
164-
e = look_through_casts(e);
156+
const exprt &e = skip_typecast(expr);
157+
165158
if(e.id() == ID_constant_interval)
166159
{
167160
return to_constant_interval_expr(e);

0 commit comments

Comments
 (0)