Skip to content

Commit 9044426

Browse files
author
Daniel Kroening
committed
added variants of goto_programt::insert_before/after that take instruction
This avoids duplicate initialization of the inserted instruction.
1 parent 33e1656 commit 9044426

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/goto-programs/goto_program.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,14 @@ class goto_programt
573573
return instructions.insert(target, instructiont());
574574
}
575575

576+
/// Insertion before the instruction pointed-to by the given instruction
577+
/// iterator `target`.
578+
/// \return newly inserted location
579+
targett insert_before(const_targett target, const instructiont &i)
580+
{
581+
return instructions.insert(target, i);
582+
}
583+
576584
/// Insertion after the instruction pointed-to by the given instruction
577585
/// iterator `target`.
578586
/// \return newly inserted location
@@ -581,6 +589,14 @@ class goto_programt
581589
return instructions.insert(std::next(target), instructiont());
582590
}
583591

592+
/// Insertion after the instruction pointed-to by the given instruction
593+
/// iterator `target`.
594+
/// \return newly inserted location
595+
targett insert_after(const_targett target, const instructiont &i)
596+
{
597+
return instructions.insert(std::next(target), i);
598+
}
599+
584600
/// Appends the given program `p` to `*this`. `p` is destroyed.
585601
void destructive_append(goto_programt &p)
586602
{

0 commit comments

Comments
 (0)