Skip to content

Commit 0c079da

Browse files
author
Daniel Kroening
committed
remove goto_programt::instructiont::function member
1 parent f1489fd commit 0c079da

9 files changed

+4
-102
lines changed

src/goto-programs/generate_function_bodies.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class assume_false_generate_function_bodiest : public generate_function_bodiest
7171
// NOLINTNEXTLINE
7272
auto add_instruction = [&]() {
7373
auto instruction = function.body.add_instruction();
74-
instruction->function = function_name;
7574
instruction->source_location = function_symbol.location;
7675
return instruction;
7776
};
@@ -94,7 +93,6 @@ class assert_false_generate_function_bodiest : public generate_function_bodiest
9493
// NOLINTNEXTLINE
9594
auto add_instruction = [&]() {
9695
auto instruction = function.body.add_instruction();
97-
instruction->function = function_name;
9896
instruction->source_location = function_symbol.location;
9997
instruction->source_location.set_function(function_name);
10098
return instruction;
@@ -125,7 +123,6 @@ class assert_false_then_assume_false_generate_function_bodiest
125123
// NOLINTNEXTLINE
126124
auto add_instruction = [&]() {
127125
auto instruction = function.body.add_instruction();
128-
instruction->function = function_name;
129126
instruction->source_location = function_symbol.location;
130127
instruction->source_location.set_function(function_name);
131128
return instruction;
@@ -261,7 +258,6 @@ class havoc_generate_function_bodiest : public generate_function_bodiest,
261258
// NOLINTNEXTLINE
262259
auto add_instruction = [&]() {
263260
auto instruction = function.body.add_instruction();
264-
instruction->function = function_name;
265261
instruction->source_location = function_symbol.location;
266262
return instruction;
267263
};

src/goto-programs/goto_convert_functions.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ void goto_convert_functionst::convert_function(
204204
// add "end of function"
205205
f.body.destructive_append(tmp_end_function);
206206

207-
// do function tags (they are empty at this point)
208-
f.update_instructions_function(identifier);
209-
210207
f.body.update();
211208

212209
if(hide(f.body))

src/goto-programs/goto_function.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ class goto_functiont
7171
parameter_identifiers.clear();
7272
}
7373

74-
/// update the function member in each instruction
75-
/// \param function_id: the `function_id` used for assigning empty function
76-
/// members
77-
void update_instructions_function(const irep_idt &function_id)
78-
{
79-
body.update_instructions_function(function_id);
80-
}
81-
8274
void swap(goto_functiont &other)
8375
{
8476
body.swap(other.body);

src/goto-programs/goto_functions.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,12 @@ class goto_functionst
8282
void compute_target_numbers();
8383
void compute_incoming_edges();
8484

85-
/// update the function member in each instruction by setting it to
86-
/// the goto function's identifier
87-
void update_instructions_function()
88-
{
89-
for(auto &func : function_map)
90-
{
91-
func.second.update_instructions_function(func.first);
92-
}
93-
}
94-
9585
void update()
9686
{
9787
compute_incoming_edges();
9888
compute_target_numbers();
9989
compute_location_numbers();
10090
compute_loop_numbers();
101-
update_instructions_function();
10291
}
10392

10493
/// Get the identifier of the entry point to a goto model

src/goto-programs/goto_inline.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,12 @@ void goto_function_inline(
244244
const irep_idt function,
245245
const namespacet &ns,
246246
message_handlert &message_handler,
247-
bool adjust_function,
248247
bool caching)
249248
{
250249
goto_inlinet goto_inline(
251250
goto_functions,
252251
ns,
253252
message_handler,
254-
adjust_function,
255253
caching);
256254

257255
goto_functionst::function_mapt::iterator f_it=

src/goto-programs/goto_inline_class.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ void goto_inlinet::parameter_assignments(
6666
decl->code=code_declt(symbol.symbol_expr());
6767
decl->code.add_source_location()=source_location;
6868
decl->source_location=source_location;
69-
decl->function=adjust_function?target->function:function_name;
7069
}
7170

7271
// this is the actual parameter
@@ -129,8 +128,6 @@ void goto_inlinet::parameter_assignments(
129128
dest.add_instruction(ASSIGN);
130129
dest.instructions.back().source_location=source_location;
131130
dest.instructions.back().code.swap(assignment);
132-
dest.instructions.back().function=
133-
adjust_function?target->function:function_name;
134131
}
135132

136133
if(it1!=arguments.end())
@@ -174,7 +171,6 @@ void goto_inlinet::parameter_destruction(
174171
dead->code=code_deadt(symbol.symbol_expr());
175172
dead->code.add_source_location()=source_location;
176173
dead->source_location=source_location;
177-
dead->function=adjust_function?target->function:function_name;
178174
}
179175
}
180176
}
@@ -281,10 +277,6 @@ void goto_inlinet::insert_function_body(
281277
"final instruction of a function must be an END_FUNCTION");
282278
end.type=LOCATION;
283279

284-
if(adjust_function)
285-
for(auto &instruction : body.instructions)
286-
instruction.function=target->function;
287-
288280
replace_return(body, lhs);
289281

290282
goto_programt tmp1;

src/goto-programs/goto_model.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,6 @@ class goto_model_functiont
172172
goto_functions.compute_location_numbers(goto_function.body);
173173
}
174174

175-
/// Updates the empty function member of each instruction by setting them
176-
/// to `function_id`
177-
void update_instructions_function()
178-
{
179-
goto_function.update_instructions_function(function_id);
180-
}
181-
182175
/// Get symbol table
183176
/// \return journalling symbol table that (a) wraps the global symbol table,
184177
/// and (b) has recorded all symbol mutations (insertions, updates and

src/goto-programs/goto_program.h

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ class goto_programt
178178
public:
179179
codet code;
180180

181-
/// The function this instruction belongs to
182-
irep_idt function;
183-
184181
/// The location of the instruction in the source file
185182
source_locationt source_location;
186183

@@ -347,7 +344,6 @@ class goto_programt
347344
swap(instruction.type, type);
348345
swap(instruction.guard, guard);
349346
swap(instruction.targets, targets);
350-
swap(instruction.function, function);
351347
}
352348

353349
#if (defined _MSC_VER && _MSC_VER <= 1800)
@@ -424,42 +420,6 @@ class goto_programt
424420
return t;
425421
}
426422

427-
/// Get the id of the function that contains the instruction pointed-to by the
428-
/// given instruction iterator.
429-
///
430-
/// \param l: instruction iterator
431-
/// \return id of the function that contains the pointed-to goto instruction
432-
static const irep_idt get_function_id(
433-
const_targett l)
434-
{
435-
// The field `function` of an instruction may not always contain the id of
436-
// the function it is currently in, due to goto program modifications such
437-
// as inlining. For example, if an instruction in a function `f` is inlined
438-
// into a function `g`, the instruction may, depending on the arguments to
439-
// the inliner, retain the original value of `f` in the function field.
440-
// However, instructions of type END_FUNCTION are never inlined into other
441-
// functions, hence they contain the id of the function they are in. Thus,
442-
// this function takes the END_FUNCTION instruction of the goto program and
443-
// returns the value of its function field.
444-
445-
while(!l->is_end_function())
446-
++l;
447-
448-
return l->function;
449-
}
450-
451-
/// Get the id of the function that contains the given goto program.
452-
///
453-
/// \param p: the goto program
454-
/// \return id of the function that contains the goto program
455-
static const irep_idt get_function_id(
456-
const goto_programt &p)
457-
{
458-
PRECONDITION(!p.empty());
459-
460-
return get_function_id(--p.instructions.end());
461-
}
462-
463423
template <typename Target>
464424
std::list<Target> get_successors(Target target) const;
465425

@@ -578,22 +538,6 @@ class goto_programt
578538
}
579539
}
580540

581-
/// Sets the `function` member of each instruction if not yet set
582-
/// Note that a goto program need not be a goto function and therefore,
583-
/// we cannot do this in update(), but only at the level of
584-
/// of goto_functionst where goto programs are guaranteed to be
585-
/// named functions.
586-
void update_instructions_function(const irep_idt &function_id)
587-
{
588-
for(auto &instruction : instructions)
589-
{
590-
if(instruction.function.empty())
591-
{
592-
instruction.function = function_id;
593-
}
594-
}
595-
}
596-
597541
/// Compute location numbers
598542
void compute_location_numbers()
599543
{
@@ -608,9 +552,11 @@ class goto_programt
608552
void update();
609553

610554
/// Human-readable loop name
611-
static irep_idt loop_id(const instructiont &instruction)
555+
static irep_idt loop_id(
556+
const irep_idt &function_id,
557+
const instructiont &instruction)
612558
{
613-
return id2string(instruction.function)+"."+
559+
return id2string(function_id)+"."+
614560
std::to_string(instruction.loop_number);
615561
}
616562

src/goto-programs/parameter_assignments.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ void parameter_assignmentst::do_function_calls(
7676
if(rhs.type()!=lhs.type())
7777
rhs.make_typecast(lhs.type());
7878
t->code=code_assignt(lhs, rhs);
79-
t->function=i_it->function;
8079
}
8180
}
8281

0 commit comments

Comments
 (0)