Skip to content

Commit 8f0a78d

Browse files
committed
Add method to get a const_targett from a location number
1 parent c1bfa90 commit 8f0a78d

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
@@ -529,6 +529,23 @@ class goto_programt
529529
return t;
530530
}
531531

532+
optionalt<const_targett> get_target(const unsigned location_number) const
533+
{
534+
PRECONDITION(!instructions.empty());
535+
536+
const unsigned start_location_number = instructions.front().location_number;
537+
538+
if(
539+
location_number < start_location_number ||
540+
location_number > instructions.back().location_number)
541+
{
542+
return nullopt;
543+
}
544+
545+
return std::next(
546+
instructions.begin(), location_number - start_location_number);
547+
}
548+
532549
template <typename Target>
533550
std::list<Target> get_successors(Target target) const;
534551

0 commit comments

Comments
 (0)