Skip to content

Improve replace_symbolt precondition message #5219

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
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
8 changes: 6 additions & 2 deletions src/util/replace_symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ void replace_symbolt::insert(
const symbol_exprt &old_expr,
const exprt &new_expr)
{
PRECONDITION(old_expr.type() == new_expr.type());
PRECONDITION_WITH_DIAGNOSTICS(
old_expr.type() == new_expr.type(),
"types to be replaced should match. old type:\n" +
old_expr.type().pretty() + "\nnew.type:\n" + new_expr.type().pretty());
expr_map.insert(std::pair<irep_idt, exprt>(
old_expr.get_identifier(), new_expr));
}
Expand All @@ -46,7 +49,8 @@ bool replace_symbolt::replace_symbol_expr(symbol_exprt &s) const

DATA_INVARIANT(
s.type() == it->second.type(),
"type of symbol to be replaced should match");
"types to be replaced should match. s.type:\n" + s.type().pretty() +
"\nit->second.type:\n" + it->second.type().pretty());
static_cast<exprt &>(s) = it->second;

return false;
Expand Down