Skip to content

Commit 71c77d2

Browse files
committed
Goto conversion: fix missing source locations
Cleaning of &&/|| introduced `GOTO` and `SKIP` instructions without a source location.
1 parent 4ae54e6 commit 71c77d2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Diff for: src/ansi-c/goto-conversion/goto_clean_expr.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,15 @@ void goto_convertt::rewrite_boolean(exprt &expr)
114114
"' must be Boolean, but got ",
115115
irep_pretty_diagnosticst{expr});
116116

117+
const source_locationt source_location = expr.find_source_location();
118+
117119
// re-write "a ==> b" into a?b:1
118120
if(auto implies = expr_try_dynamic_cast<implies_exprt>(expr))
119121
{
120122
expr = if_exprt{
121123
std::move(implies->lhs()),
122124
std::move(implies->rhs()),
123-
true_exprt{},
125+
true_exprt{}.with_source_location(source_location),
124126
bool_typet{}};
125127
return;
126128
}
@@ -135,6 +137,8 @@ void goto_convertt::rewrite_boolean(exprt &expr)
135137
else // ID_or
136138
tmp = false_exprt();
137139

140+
tmp.add_source_location() = source_location;
141+
138142
exprt::operandst &ops = expr.operands();
139143

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

151155
if(expr.id() == ID_and)
152156
{
153-
if_exprt if_e(op, tmp, false_exprt());
157+
exprt if_e =
158+
if_exprt{op, tmp, false_exprt{}.with_source_location(source_location)}
159+
.with_source_location(source_location);
154160
tmp.swap(if_e);
155161
continue;
156162
}
157163
if(expr.id() == ID_or)
158164
{
159-
if_exprt if_e(op, true_exprt(), tmp);
165+
exprt if_e =
166+
if_exprt{op, true_exprt{}.with_source_location(source_location), tmp}
167+
.with_source_location(source_location);
160168
tmp.swap(if_e);
161169
continue;
162170
}

Diff for: src/goto-programs/remove_function_pointers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ static void fix_return_type(
236236
exprt old_lhs=function_call.lhs();
237237
function_call.lhs()=tmp_symbol_expr;
238238

239-
dest.add(goto_programt::make_assignment(code_assignt(
239+
dest.add(goto_programt::make_assignment(
240240
old_lhs,
241241
make_byte_extract(
242242
tmp_symbol_expr, from_integer(0, c_index_type()), old_lhs.type()),
243-
source_location)));
243+
source_location));
244244
}
245245

246246
void remove_function_pointerst::remove_function_pointer(

0 commit comments

Comments
 (0)