Skip to content

Commit 0623219

Browse files
committed
generate-function-body: set function in source_location
This was set in only one of the three cases.
1 parent 40e0123 commit 0623219

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/goto-instrument/generate_function_bodies.cpp

+20-18
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ class assume_false_generate_function_bodiest : public generate_function_bodiest
7676
const irep_idt &function_name) const override
7777
{
7878
auto const &function_symbol = symbol_table.lookup_ref(function_name);
79-
function.body.add(
80-
goto_programt::make_assumption(false_exprt(), function_symbol.location));
81-
function.body.add(
82-
goto_programt::make_end_function(function_symbol.location));
79+
source_locationt location = function_symbol.location;
80+
location.set_function(function_name);
81+
82+
function.body.add(goto_programt::make_assumption(false_exprt(), location));
83+
function.body.add(goto_programt::make_end_function(location));
8384
}
8485
};
8586

@@ -249,6 +250,8 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
249250
}
250251

251252
auto const &function_symbol = symbol_table.lookup_ref(function_name);
253+
source_locationt location = function_symbol.location;
254+
location.set_function(function_name);
252255

253256
for(std::size_t i = 0; i < function.parameter_identifiers.size(); ++i)
254257
{
@@ -266,7 +269,7 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
266269
equal_exprt(
267270
parameter_symbol.symbol_expr(),
268271
null_pointer_exprt(to_pointer_type(parameter_symbol.type))),
269-
function_symbol.location));
272+
location));
270273

271274
dereference_exprt dereference_expr(
272275
parameter_symbol.symbol_expr(),
@@ -276,15 +279,15 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
276279
havoc_expr_rec(
277280
dereference_expr,
278281
1, // depth 1 since we pass the dereferenced pointer
279-
function_symbol.location,
282+
location,
280283
function_name,
281284
symbol_table,
282285
dest);
283286

284287
function.body.destructive_append(dest);
285288

286289
auto label_instruction =
287-
function.body.add(goto_programt::make_skip(function_symbol.location));
290+
function.body.add(goto_programt::make_skip(location));
288291
goto_instruction->complete_goto(label_instruction);
289292
}
290293
}
@@ -298,7 +301,7 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
298301
havoc_expr_rec(
299302
symbol_exprt(global_sym.name, global_sym.type),
300303
0,
301-
function_symbol.location,
304+
location,
302305
irep_idt(),
303306
symbol_table,
304307
dest);
@@ -316,21 +319,21 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
316319
type,
317320
id2string(function_name),
318321
"return_value",
319-
function_symbol.location,
322+
location,
320323
ID_C,
321324
symbol_table);
322325

323326
aux_symbol.is_static_lifetime = false;
324327

325-
function.body.add(goto_programt::make_decl(
326-
aux_symbol.symbol_expr(), function_symbol.location));
328+
function.body.add(
329+
goto_programt::make_decl(aux_symbol.symbol_expr(), location));
327330

328331
goto_programt dest;
329332

330333
havoc_expr_rec(
331334
aux_symbol.symbol_expr(),
332335
0,
333-
function_symbol.location,
336+
location,
334337
function_name,
335338
symbol_table,
336339
dest);
@@ -340,15 +343,14 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
340343
exprt return_expr =
341344
typecast_exprt::conditional_cast(aux_symbol.symbol_expr(), return_type);
342345

343-
function.body.add(goto_programt::make_set_return_value(
344-
std::move(return_expr), function_symbol.location));
346+
function.body.add(
347+
goto_programt::make_set_return_value(std::move(return_expr), location));
345348

346-
function.body.add(goto_programt::make_dead(
347-
aux_symbol.symbol_expr(), function_symbol.location));
349+
function.body.add(
350+
goto_programt::make_dead(aux_symbol.symbol_expr(), location));
348351
}
349352

350-
function.body.add(
351-
goto_programt::make_end_function(function_symbol.location));
353+
function.body.add(goto_programt::make_end_function(location));
352354

353355
remove_skip(function.body);
354356
}

0 commit comments

Comments
 (0)