Skip to content

Commit f9891b9

Browse files
committed
goto-symex: use function and called_function fields
goto_programt::instructionst::instructiont::function is going to go away, use the fields that are already available within goto-symex.
1 parent fca695a commit f9891b9

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

src/goto-checker/symex_bmc.cpp

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

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

src/goto-programs/goto_program.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,10 @@ class goto_programt
616616
void update();
617617

618618
/// Human-readable loop name
619-
static irep_idt loop_id(const instructiont &instruction)
619+
static irep_idt
620+
loop_id(const irep_idt &function_id, const instructiont &instruction)
620621
{
621-
return id2string(instruction.function)+"."+
622+
return id2string(function_id) + "." +
622623
std::to_string(instruction.loop_number);
623624
}
624625

src/goto-symex/goto_symex_state.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ void goto_symex_statet::print_backtrace(std::ostream &out) const
764764
return;
765765
}
766766

767-
out << source.pc->function << " " << source.pc->location_number << "\n";
767+
out << source.function << " " << source.pc->location_number << "\n";
768768

769769
for(auto stackit = threads[source.thread_nr].call_stack.rbegin(),
770770
stackend = threads[source.thread_nr].call_stack.rend();
@@ -774,7 +774,7 @@ void goto_symex_statet::print_backtrace(std::ostream &out) const
774774
const auto &frame = *stackit;
775775
if(frame.calling_location.is_set)
776776
{
777-
out << frame.calling_location.pc->function << " "
777+
out << frame.calling_location.function << " "
778778
<< frame.calling_location.pc->location_number << "\n";
779779
}
780780
}

src/goto-symex/symex_goto.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ void goto_symext::symex_goto(statet &state)
8585
return;
8686
}
8787

88-
unsigned &unwind=
89-
frame.loop_iterations[goto_programt::loop_id(*state.source.pc)].count;
88+
const auto loop_id =
89+
goto_programt::loop_id(state.source.function, *state.source.pc);
90+
91+
unsigned &unwind = frame.loop_iterations[loop_id].count;
9092
unwind++;
9193

9294
if(should_stop_unwind(state.source, state.call_stack(), unwind))

src/goto-symex/symex_main.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ void symex_transition(
5757
if(i_e->is_goto() && i_e->is_backwards_goto() &&
5858
(!is_backwards_goto ||
5959
state.source.pc->location_number>i_e->location_number))
60-
frame.loop_iterations[goto_programt::loop_id(*i_e)].count=0;
60+
{
61+
const auto loop_id =
62+
goto_programt::loop_id(state.source.function, *i_e);
63+
frame.loop_iterations[loop_id].count = 0;
64+
}
6165
}
6266

6367
state.source.pc=to;
@@ -156,19 +160,18 @@ void goto_symext::initialize_entry_point(
156160
state.top().calling_location.pc=state.top().end_of_function;
157161
state.symex_target=&target;
158162

159-
INVARIANT(
160-
!pc->function.empty(), "all symexed instructions should have a function");
161-
162-
const goto_functiont &entry_point_function = get_goto_function(pc->function);
163+
const goto_functiont &entry_point_function =
164+
get_goto_function(function_identifier);
163165

164166
state.top().hidden_function = entry_point_function.is_hidden();
165167

166168
auto emplace_safe_pointers_result =
167-
state.safe_pointers.emplace(pc->function, local_safe_pointerst{ns});
169+
state.safe_pointers.emplace(function_identifier, local_safe_pointerst{ns});
168170
if(emplace_safe_pointers_result.second)
169171
emplace_safe_pointers_result.first->second(entry_point_function.body);
170172

171-
state.dirty.populate_dirty_for_function(pc->function, entry_point_function);
173+
state.dirty.populate_dirty_for_function(
174+
function_identifier, entry_point_function);
172175

173176
symex_transition(state, state.source.pc, false);
174177
}

0 commit comments

Comments
 (0)