Skip to content

Commit 51cbccf

Browse files
committed
Remove {r,w,rw}_ok and pointer_in_range expansion from C front-end
These expressions are now handled by the back-ends. Unconditional rewrites by goto_check_ct (even when no checks are enabled) are no longer necessary. Fixes: diffblue#7377
1 parent b3bfff5 commit 51cbccf

File tree

1 file changed

+0
-59
lines changed

1 file changed

+0
-59
lines changed

src/ansi-c/goto_check_c.cpp

-59
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ class goto_check_ct
226226
void conversion_check(const exprt &, const guardt &);
227227
void float_overflow_check(const exprt &, const guardt &);
228228
void nan_check(const exprt &, const guardt &);
229-
optionalt<exprt> expand_pointer_checks(exprt);
230229

231230
std::string array_name(const exprt &);
232231

@@ -1994,62 +1993,6 @@ void goto_check_ct::check(const exprt &expr)
19941993
check_rec(expr, identity);
19951994
}
19961995

1997-
/// expand the r_ok, w_ok, rw_ok, pointer_in_range predicates
1998-
optionalt<exprt> goto_check_ct::expand_pointer_checks(exprt expr)
1999-
{
2000-
bool modified = false;
2001-
2002-
for(auto &op : expr.operands())
2003-
{
2004-
auto op_result = expand_pointer_checks(op);
2005-
if(op_result.has_value())
2006-
{
2007-
op = *op_result;
2008-
modified = true;
2009-
}
2010-
}
2011-
2012-
if(expr.id() == ID_r_ok || expr.id() == ID_w_ok || expr.id() == ID_rw_ok)
2013-
{
2014-
// these get an address as first argument and a size as second
2015-
DATA_INVARIANT(
2016-
expr.operands().size() == 4, "r/w_ok must have four operands");
2017-
2018-
const auto conditions = get_pointer_dereferenceable_conditions(
2019-
to_r_or_w_ok_expr(expr).pointer(), to_r_or_w_ok_expr(expr).size());
2020-
2021-
exprt::operandst conjuncts;
2022-
2023-
for(const auto &c : conditions)
2024-
conjuncts.push_back(c.assertion);
2025-
2026-
exprt c = conjunction(conjuncts);
2027-
if(enable_simplify)
2028-
simplify(c, ns);
2029-
return c;
2030-
}
2031-
else if(expr.id() == ID_pointer_in_range)
2032-
{
2033-
const auto &pointer_in_range_expr = to_pointer_in_range_expr(expr);
2034-
2035-
auto expanded = pointer_in_range_expr.lower(ns);
2036-
2037-
// rec. call
2038-
auto expanded_rec_opt = expand_pointer_checks(expanded);
2039-
if(expanded_rec_opt.has_value())
2040-
expanded = *expanded_rec_opt;
2041-
2042-
if(enable_simplify)
2043-
simplify(expanded, ns);
2044-
2045-
return expanded;
2046-
}
2047-
else if(modified)
2048-
return std::move(expr);
2049-
else
2050-
return {};
2051-
}
2052-
20531996
void goto_check_ct::memory_leak_check(const irep_idt &function_id)
20541997
{
20551998
const symbolt &leak = ns.lookup(CPROVER_PREFIX "memory_leak");
@@ -2269,8 +2212,6 @@ void goto_check_ct::goto_check(
22692212
}
22702213
}
22712214

2272-
i.transform([this](exprt expr) { return expand_pointer_checks(expr); });
2273-
22742215
for(auto &instruction : new_code.instructions)
22752216
{
22762217
if(instruction.source_location().is_nil())

0 commit comments

Comments
 (0)