Skip to content

Commit a3d8822

Browse files
committed
Remove {r,w,rw}_ok and pointer_in_range expansion from C front-end
These expressions are now rewritten to their prophecy_* counterparts by goto-program conversion, and back-ends directly handle these prophecy_* expressions. Unconditional rewrites by goto_check_ct (even when no checks are enabled) are no longer necessary. Fixes: diffblue#7377
1 parent d982027 commit a3d8822

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
@@ -228,7 +228,6 @@ class goto_check_ct
228228
void conversion_check(const exprt &, const guardt &);
229229
void float_overflow_check(const exprt &, const guardt &);
230230
void nan_check(const exprt &, const guardt &);
231-
optionalt<exprt> expand_pointer_checks(exprt);
232231

233232
std::string array_name(const exprt &);
234233

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

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

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

0 commit comments

Comments
 (0)