Skip to content

Commit 41a3034

Browse files
authored
Merge pull request #2149 from tautschnig/add-function
generate-function-body: set function in source_location
2 parents 7bc409b + 56fda10 commit 41a3034

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
@@ -75,10 +75,11 @@ class assume_false_generate_function_bodiest : public generate_function_bodiest
7575
const irep_idt &function_name) const override
7676
{
7777
auto const &function_symbol = symbol_table.lookup_ref(function_name);
78-
function.body.add(
79-
goto_programt::make_assumption(false_exprt(), function_symbol.location));
80-
function.body.add(
81-
goto_programt::make_end_function(function_symbol.location));
78+
source_locationt location = function_symbol.location;
79+
location.set_function(function_name);
80+
81+
function.body.add(goto_programt::make_assumption(false_exprt(), location));
82+
function.body.add(goto_programt::make_end_function(location));
8283
}
8384
};
8485

@@ -248,6 +249,8 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
248249
}
249250

250251
auto const &function_symbol = symbol_table.lookup_ref(function_name);
252+
source_locationt location = function_symbol.location;
253+
location.set_function(function_name);
251254

252255
for(std::size_t i = 0; i < function.parameter_identifiers.size(); ++i)
253256
{
@@ -265,7 +268,7 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
265268
equal_exprt(
266269
parameter_symbol.symbol_expr(),
267270
null_pointer_exprt(to_pointer_type(parameter_symbol.type))),
268-
function_symbol.location));
271+
location));
269272

270273
dereference_exprt dereference_expr(
271274
parameter_symbol.symbol_expr(),
@@ -275,15 +278,15 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
275278
havoc_expr_rec(
276279
dereference_expr,
277280
1, // depth 1 since we pass the dereferenced pointer
278-
function_symbol.location,
281+
location,
279282
function_name,
280283
symbol_table,
281284
dest);
282285

283286
function.body.destructive_append(dest);
284287

285288
auto label_instruction =
286-
function.body.add(goto_programt::make_skip(function_symbol.location));
289+
function.body.add(goto_programt::make_skip(location));
287290
goto_instruction->complete_goto(label_instruction);
288291
}
289292
}
@@ -297,7 +300,7 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
297300
havoc_expr_rec(
298301
symbol_exprt(global_sym.name, global_sym.type),
299302
0,
300-
function_symbol.location,
303+
location,
301304
irep_idt(),
302305
symbol_table,
303306
dest);
@@ -315,21 +318,21 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
315318
type,
316319
id2string(function_name),
317320
"return_value",
318-
function_symbol.location,
321+
location,
319322
ID_C,
320323
symbol_table);
321324

322325
aux_symbol.is_static_lifetime = false;
323326

324-
function.body.add(goto_programt::make_decl(
325-
aux_symbol.symbol_expr(), function_symbol.location));
327+
function.body.add(
328+
goto_programt::make_decl(aux_symbol.symbol_expr(), location));
326329

327330
goto_programt dest;
328331

329332
havoc_expr_rec(
330333
aux_symbol.symbol_expr(),
331334
0,
332-
function_symbol.location,
335+
location,
333336
function_name,
334337
symbol_table,
335338
dest);
@@ -339,15 +342,14 @@ class havoc_generate_function_bodiest : public generate_function_bodiest
339342
exprt return_expr =
340343
typecast_exprt::conditional_cast(aux_symbol.symbol_expr(), return_type);
341344

342-
function.body.add(goto_programt::make_set_return_value(
343-
std::move(return_expr), function_symbol.location));
345+
function.body.add(
346+
goto_programt::make_set_return_value(std::move(return_expr), location));
344347

345-
function.body.add(goto_programt::make_dead(
346-
aux_symbol.symbol_expr(), function_symbol.location));
348+
function.body.add(
349+
goto_programt::make_dead(aux_symbol.symbol_expr(), location));
347350
}
348351

349-
function.body.add(
350-
goto_programt::make_end_function(function_symbol.location));
352+
function.body.add(goto_programt::make_end_function(location));
351353

352354
remove_skip(function.body);
353355
}

0 commit comments

Comments
 (0)