Skip to content

Commit d1eae28

Browse files
author
Daniel Kroening
committed
remove goto_programt::instructiont::function member
1 parent f340f08 commit d1eae28

15 files changed

+9
-111
lines changed

src/cbmc/symex_bmc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ bool symex_bmct::get_unwind(
109109
const goto_symex_statet::call_stackt &context,
110110
unsigned unwind)
111111
{
112-
const irep_idt id=goto_programt::loop_id(*source.pc);
112+
const irep_idt id = goto_programt::loop_id(source.function, *source.pc);
113113

114114
tvt abort_unwind_decision;
115115
unsigned this_loop_limit=std::numeric_limits<unsigned>::max();

src/goto-instrument/branch.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ void branch(
5353
goto_programt::targett t1=body.insert_after(i_it);
5454
t1->make_function_call(
5555
function_to_call(goto_model.symbol_table, id, "taken"));
56-
t1->function=f_it->first;
5756

5857
goto_programt::targett t2=body.insert_after(t1);
5958
t2->make_goto(i_it->get_target());
6059

6160
goto_programt::targett t3=body.insert_after(t2);
6261
t3->make_function_call(
6362
function_to_call(goto_model.symbol_table, id, "not-taken"));
64-
t3->function=f_it->first;
6563
i_it->targets.clear();
6664
i_it->targets.push_back(t3);
6765
}

src/goto-instrument/cover_instrument.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class cover_instrumenter_baset
7171
t->source_location.set(ID_coverage_criterion, coverage_criterion);
7272
t->source_location.set_property_class(property_class);
7373
t->source_location.set_function(function);
74-
t->function = function;
7574
}
7675

7776
bool is_non_cover_assertion(goto_programt::const_targett t) const

src/goto-instrument/cover_instrument_mcdc.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ void cover_mcdc_instrumentert::instrument(
668668
i_it->source_location.set(ID_coverage_criterion, coverage_criterion);
669669
i_it->source_location.set_property_class(property_class);
670670
i_it->source_location.set_function(function);
671-
i_it->function = function;
672671

673672
std::string comment_f = description + " `" + p_string + "' false";
674673
goto_program.insert_before_swap(i_it);
@@ -678,7 +677,6 @@ void cover_mcdc_instrumentert::instrument(
678677
i_it->source_location.set(ID_coverage_criterion, coverage_criterion);
679678
i_it->source_location.set_property_class(property_class);
680679
i_it->source_location.set_function(function);
681-
i_it->function = function;
682680
}
683681

684682
std::set<exprt> controlling;

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
// make sure the inlined function does not introduce hiding
289281
if(goto_function.is_hidden())
290282
{

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: 3 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,10 @@ 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
556+
loop_id(const irep_idt &function_id, const instructiont &instruction)
612557
{
613-
return id2string(instruction.function)+"."+
558+
return id2string(function_id) + "." +
614559
std::to_string(instruction.loop_number);
615560
}
616561

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

src/goto-programs/read_bin_goto_object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static bool read_bin_goto_object_v4(
100100
goto_programt::instructiont &instruction=*itarget;
101101

102102
irepconverter.reference_convert(in, instruction.code);
103-
instruction.function = irepconverter.read_string_ref(in);
103+
irepconverter.read_string_ref(in); // former function
104104
irepconverter.reference_convert(in, instruction.source_location);
105105
instruction.type = (goto_program_instruction_typet)
106106
irepconverter.read_gb_word(in);

src/goto-symex/symex_goto.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ void goto_symext::symex_goto(statet &state)
8282
return;
8383
}
8484

85-
unsigned &unwind=
86-
frame.loop_iterations[goto_programt::loop_id(*state.source.pc)].count;
85+
const auto &loop_id =
86+
goto_programt::loop_id(state.source.function, *state.source.pc);
87+
88+
unsigned &unwind = frame.loop_iterations[loop_id].count;
8789
unwind++;
8890

8991
// continue unwinding?

0 commit comments

Comments
 (0)