Skip to content

Commit 62cb205

Browse files
committed
Goto-symex: add documentation to let-lifting and related functions
1 parent a69e95d commit 62cb205

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/goto-symex/goto_symex.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,28 @@ class goto_symext
274274
/// \param expr: The expression to clean up
275275
/// \param state
276276
/// \param write
277+
/// \return owning object for any let-bound variables created as part of
278+
/// cleaning this expression, and which will be killed when the object is
279+
/// allowed to die. The caller should store it or move or return it to an
280+
/// appropriate scope such that it dies only when no new references to a
281+
/// let-bound variable could be created (usually, when the enclosing
282+
/// instruction is done executing)
277283
NODISCARD symex_live_let_variablest
278284
clean_expr(exprt &expr, statet &state, bool write);
279285

280286
void trigger_auto_object(const exprt &, statet &);
281287
void initialize_auto_object(const exprt &, statet &);
288+
289+
/// Given an expression, find the root object and the offset into it.
290+
///
291+
/// The extra complication to be considered here is that the expression may
292+
/// have any number of ternary expressions mixed with type casts.
293+
/// \return owning object for any let-bound variables created as part of
294+
/// cleaning this expression, and which will be killed when the object is
295+
/// allowed to die. The caller should store it or move or return it to an
296+
/// appropriate scope such that it dies only when no new references to a
297+
/// let-bound variable could be created (usually, when the enclosing
298+
/// instruction is done executing)
282299
NODISCARD symex_live_let_variablest process_array_expr(statet &, exprt &);
283300
exprt make_auto_object(const typet &, statet &);
284301
virtual void dereference(exprt &, statet &, bool write);
@@ -498,7 +515,21 @@ class goto_symext
498515

499516
typedef symex_targett::assignment_typet assignment_typet;
500517

518+
/// Execute any let expressions in \p expr using \ref symex_assign_symbol.
519+
/// The assignments will be made in bottom-up topological but otherwise
520+
/// arbitrary order (i.e. in `(let x = let y = 0 in x + y) + (let z = 0 in z)
521+
/// we will define `y` before `x`, but `z` and `x` could come in either order)
522+
/// \return owning object for any let-bound variables created, and which will
523+
/// be killed when the object is allowed to die. The caller should store it
524+
/// or move or return it to an appropriate scope such that it dies only when
525+
/// no new references to a let-bound variable could be created (usually,
526+
/// when the enclosing instruction is done executing)
501527
NODISCARD symex_live_let_variablest lift_lets(statet &, exprt &expr);
528+
529+
/// Execute a single let expression, which should not have any nested let
530+
/// expressions (use \ref lift_lets instead if there might be).
531+
/// The caller is responsible for killing the newly-defined variable when
532+
/// appropriate.
502533
void lift_let(statet &state, const let_exprt &let_expr);
503534

504535
void symex_assign_rec(

0 commit comments

Comments
 (0)