Skip to content

Commit 5fc1cba

Browse files
committed
Goto-symex: add documentation to let-lifting and related functions
1 parent 1f94ed3 commit 5fc1cba

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/goto-symex/goto_symex.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,27 @@ 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
symex_live_let_variablest clean_expr(exprt &expr, statet &state, bool write);
278284

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

498515
typedef symex_targett::assignment_typet assignment_typet;
499516

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

503534
void symex_assign_rec(

0 commit comments

Comments
 (0)