Skip to content

Commit 573ad9c

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 89d4fa7 commit 573ad9c

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
@@ -615,6 +615,14 @@ class goto_programt
615615
return instructions.insert(target, instructiont());
616616
}
617617

618+
/// Insertion before the instruction pointed-to by the given instruction
619+
/// iterator `target`.
620+
/// \return newly inserted location
621+
targett insert_before(const_targett target, instructiont &&i)
622+
{
623+
return instructions.insert(target, std::move(i));
624+
}
625+
618626
/// Insertion after the instruction pointed-to by the given instruction
619627
/// iterator `target`.
620628
/// \return newly inserted location
@@ -623,6 +631,14 @@ class goto_programt
623631
return instructions.insert(std::next(target), instructiont());
624632
}
625633

634+
/// Insertion after the instruction pointed-to by the given instruction
635+
/// iterator `target`.
636+
/// \return newly inserted location
637+
targett insert_after(const_targett target, instructiont &&i)
638+
{
639+
return instructions.insert(std::next(target), std::move(i));
640+
}
641+
626642
/// Appends the given program `p` to `*this`. `p` is destroyed.
627643
void destructive_append(goto_programt &p)
628644
{

0 commit comments

Comments
 (0)