Skip to content

Remove and replace use of look_through_casts #6544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions jbmc/src/java_bytecode/java_pointer_casts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]

#include "java_pointer_casts.h"

#include <util/expr_util.h>
#include <util/namespace.h>
#include <util/pointer_expr.h>
#include <util/std_expr.h>
Expand Down Expand Up @@ -64,21 +65,6 @@ bool find_superclass_with_type(
}
}


/// \par parameters: input expression
/// \return recursively search target of typecast
static const exprt &look_through_casts(const exprt &in)
{
if(in.id()==ID_typecast)
{
assert(in.type().id()==ID_pointer);
return look_through_casts(to_typecast_expr(in).op());
}
else
return in;
}


/// \par parameters: raw pointer
/// target type
/// namespace
Expand All @@ -88,7 +74,7 @@ exprt make_clean_pointer_cast(
const pointer_typet &target_type,
const namespacet &ns)
{
const exprt &ptr=look_through_casts(rawptr);
const exprt &ptr = skip_typecast(rawptr);

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

Expand Down
19 changes: 6 additions & 13 deletions src/analyses/variable-sensitivity/interval_abstract_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <util/arith_tools.h>
#include <util/bitvector_types.h>
#include <util/expr_util.h>
#include <util/invariant.h>
#include <util/make_unique.h>
#include <util/simplify_expr.h>
Expand Down Expand Up @@ -74,15 +75,6 @@ static index_range_implementation_ptrt make_interval_index_range(
return util_make_unique<interval_index_ranget>(interval, n);
}

static inline exprt look_through_casts(exprt e)
{
while(e.id() == ID_typecast)
{
e = to_typecast_expr(e).op();
}
return e;
}

static inline bool
bvint_value_is_max(const typet &type, const mp_integer &value)
{
Expand Down Expand Up @@ -153,15 +145,16 @@ interval_from_x_gt_value(const exprt &value)
return constant_interval_exprt::bottom(value.type());
}

static inline bool represents_interval(exprt e)
static inline bool represents_interval(const exprt &expr)
{
e = look_through_casts(e);
const exprt &e = skip_typecast(expr);
return (e.id() == ID_constant_interval || e.id() == ID_constant);
}

static inline constant_interval_exprt make_interval_expr(exprt e)
static inline constant_interval_exprt make_interval_expr(const exprt &expr)
{
e = look_through_casts(e);
const exprt &e = skip_typecast(expr);

if(e.id() == ID_constant_interval)
{
return to_constant_interval_expr(e);
Expand Down