@@ -11,11 +11,11 @@ Date: September 2021
1111#ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_UTILS_H
1212#define CPROVER_GOTO_INSTRUMENT_CONTRACTS_UTILS_H
1313
14- #include < vector >
14+ #include < goto-programs/goto_convert_class.h >
1515
1616#include < goto-instrument/havoc_utils.h>
1717
18- #include < goto-programs/goto_convert_class.h >
18+ #include < vector >
1919
2020#define IN_BASE_CASE " __in_base_case"
2121#define ENTERED_LOOP " __entered_loop"
@@ -110,6 +110,30 @@ void insert_before_swap_and_advance(
110110 goto_programt::targett &target,
111111 goto_programt &payload);
112112
113+ // / \brief Insert a goto instruction before a target instruction iterator
114+ // / and update targets of all jumps that points to the iterator to
115+ // / jumping to the inserted instruction. This method is intended
116+ // / to keep external instruction::targett stable, i.e. they will
117+ // / still point to the same instruction after inserting the new one
118+ // /
119+ // / This function inserts a instruction `i` into a destination program
120+ // / `destination` immediately before a specified instruction iterator `target`.
121+ // / After insertion, update all jumps that pointing to `target` to jumping to
122+ // / `i` instead.
123+ // /
124+ // / Different from `insert_before_swap_and_advance`, this function doesn't
125+ // / invalidate the iterator `target` after insertion. That is, `target` and
126+ // / all other instruction iterators same as `target` will still point to the
127+ // / same instruction after insertion.
128+ // /
129+ // / \param destination: The destination program for inserting the `i`.
130+ // / \param target: The instruction iterator at which to insert the `i`.
131+ // / \param i: The goto instruction to be inserted into the `destination`.
132+ void insert_before_and_update_jumps (
133+ goto_programt &destination,
134+ goto_programt::targett &target,
135+ const goto_programt::instructiont &i);
136+
113137// / \brief Adds a fresh and uniquely named symbol to the symbol table.
114138// /
115139// / \param type: The type of the new symbol.
@@ -192,7 +216,7 @@ void add_quantified_variable(
192216 const irep_idt &mode);
193217
194218// / This function recursively identifies the "old" expressions within expr
195- // / and replaces them with correspoding history variables.
219+ // / and replaces them with corresponding history variables.
196220void replace_history_parameter (
197221 symbol_table_baset &symbol_table,
198222 exprt &expr,
0 commit comments