Skip to content

Commit b5657a8

Browse files
committed
Add method to get a const_targett from a location number
1 parent 20ee8df commit b5657a8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/goto-programs/goto_program.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,23 @@ class goto_programt
588588
return t;
589589
}
590590

591+
optionalt<const_targett> get_target(const unsigned location_number) const
592+
{
593+
PRECONDITION(!instructions.empty());
594+
595+
const unsigned start_location_number = instructions.front().location_number;
596+
597+
if(
598+
location_number < start_location_number ||
599+
location_number > instructions.back().location_number)
600+
{
601+
return nullopt;
602+
}
603+
604+
return std::next(
605+
instructions.begin(), location_number - start_location_number);
606+
}
607+
591608
template <typename Target>
592609
std::list<Target> get_successors(Target target) const;
593610

0 commit comments

Comments
 (0)