diff --git a/src/goto-programs/goto_program.h b/src/goto-programs/goto_program.h index cadac39de4b..f597e242513 100644 --- a/src/goto-programs/goto_program.h +++ b/src/goto-programs/goto_program.h @@ -645,20 +645,26 @@ class goto_programt instructions.splice(target, p.instructions); } + /// Adds a given instruction at the end. + /// \return The newly added instruction. + targett add(instructiont &&instruction) + { + instructions.push_back(std::move(instruction)); + return --instructions.end(); + } + /// Adds an instruction at the end. /// \return The newly added instruction. targett add_instruction() { - instructions.push_back(instructiont()); - return --instructions.end(); + return add(instructiont()); } /// Adds an instruction of given type at the end. /// \return The newly added instruction. targett add_instruction(goto_program_instruction_typet type) { - instructions.push_back(instructiont(type)); - return --instructions.end(); + return add(instructiont(type)); } /// Output goto program to given stream