Skip to content
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

Goto conversion: fix missing source locations #8444

Merged
merged 1 commit into from
Sep 11, 2024
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
16 changes: 12 additions & 4 deletions src/ansi-c/goto-conversion/goto_clean_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ void goto_convertt::rewrite_boolean(exprt &expr)
"' must be Boolean, but got ",
irep_pretty_diagnosticst{expr});

const source_locationt source_location = expr.find_source_location();

// re-write "a ==> b" into a?b:1
if(auto implies = expr_try_dynamic_cast<implies_exprt>(expr))
{
expr = if_exprt{
std::move(implies->lhs()),
std::move(implies->rhs()),
true_exprt{},
true_exprt{}.with_source_location(source_location),
bool_typet{}};
return;
}
Expand All @@ -135,6 +137,8 @@ void goto_convertt::rewrite_boolean(exprt &expr)
else // ID_or
tmp = false_exprt();

tmp.add_source_location() = source_location;

exprt::operandst &ops = expr.operands();

// start with last one
Expand All @@ -146,17 +150,21 @@ void goto_convertt::rewrite_boolean(exprt &expr)
DATA_INVARIANT_WITH_DIAGNOSTICS(
op.is_boolean(),
"boolean operators must have only boolean operands",
expr.find_source_location());
source_location);

if(expr.id() == ID_and)
{
if_exprt if_e(op, tmp, false_exprt());
exprt if_e =
if_exprt{op, tmp, false_exprt{}.with_source_location(source_location)}
.with_source_location(source_location);
tmp.swap(if_e);
continue;
}
if(expr.id() == ID_or)
{
if_exprt if_e(op, true_exprt(), tmp);
exprt if_e =
if_exprt{op, true_exprt{}.with_source_location(source_location), tmp}
.with_source_location(source_location);
tmp.swap(if_e);
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/goto-programs/remove_function_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ static void fix_return_type(
exprt old_lhs=function_call.lhs();
function_call.lhs()=tmp_symbol_expr;

dest.add(goto_programt::make_assignment(code_assignt(
dest.add(goto_programt::make_assignment(
old_lhs,
make_byte_extract(
tmp_symbol_expr, from_integer(0, c_index_type()), old_lhs.type()),
source_location)));
source_location));
}

void remove_function_pointerst::remove_function_pointer(
Expand Down
Loading