Skip to content

Commit 3d2efc0

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 68bc98d commit 3d2efc0

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
@@ -694,9 +694,10 @@ class goto_programt
694694
void update();
695695

696696
/// Human-readable loop name
697-
static irep_idt loop_id(const instructiont &instruction)
697+
static irep_idt
698+
loop_id(const irep_idt &function_id, const instructiont &instruction)
698699
{
699-
return id2string(instruction.function)+"."+
700+
return id2string(function_id) + "." +
700701
std::to_string(instruction.loop_number);
701702
}
702703

src/goto-symex/goto_symex_state.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ void goto_symex_statet::print_backtrace(std::ostream &out) const
759759
return;
760760
}
761761

762-
out << source.pc->function << " " << source.pc->location_number << "\n";
762+
out << source.function << " " << source.pc->location_number << "\n";
763763

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

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
@@ -58,7 +58,11 @@ void symex_transition(
5858
if(i_e->is_goto() && i_e->is_backwards_goto() &&
5959
(!is_backwards_goto ||
6060
state.source.pc->location_number>i_e->location_number))
61-
frame.loop_iterations[goto_programt::loop_id(*i_e)].count=0;
61+
{
62+
const auto loop_id =
63+
goto_programt::loop_id(state.source.function, *i_e);
64+
frame.loop_iterations[loop_id].count = 0;
65+
}
6266
}
6367

6468
state.source.pc=to;
@@ -157,19 +161,18 @@ void goto_symext::initialize_entry_point(
157161
state.top().calling_location.pc=state.top().end_of_function;
158162
state.symex_target=&target;
159163

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

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

167169
auto emplace_safe_pointers_result =
168-
state.safe_pointers.emplace(pc->function, local_safe_pointerst{ns});
170+
state.safe_pointers.emplace(function_identifier, local_safe_pointerst{ns});
169171
if(emplace_safe_pointers_result.second)
170172
emplace_safe_pointers_result.first->second(entry_point_function.body);
171173

172-
state.dirty.populate_dirty_for_function(pc->function, entry_point_function);
174+
state.dirty.populate_dirty_for_function(
175+
function_identifier, entry_point_function);
173176

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

0 commit comments

Comments
 (0)