Skip to content

Commit fa920a3

Browse files
NlightNFotisEnrico Steffinlongo
authored and
Enrico Steffinlongo
committed
[DOCS] Minor improvements to doxygen comments of shadow_memory_util.{h, cpp}.
1 parent c864ba9 commit fa920a3

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

src/goto-symex/shadow_memory_util.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ get_field_init_type(const irep_idt &field_name, const goto_symex_statet &state)
262262
return field_init_expr.type();
263263
}
264264

265-
/// Given a pointer expression `address` checks if any expr in value_set is
266-
/// compatible
267265
bool contains_null_or_invalid(
268266
const std::vector<exprt> &value_set,
269267
const exprt &address)
@@ -350,13 +348,20 @@ static void or_elements(
350348
}
351349
}
352350

353-
// TODO: doxygen?
351+
/// Translate a list of values into an or expression. Used here in the implementation
352+
/// of aggregation of boolean-typed fields.
353+
/// \param field_type The type of the values of the or expression (expected to be
354+
/// the same).
355+
/// \param values A list (std::vector) of values collected previously, passed
356+
/// through immediatelly to the constructed expression as operands.
357+
/// \return A newly constructed or_exprt over the possible values given.
354358
static exprt or_values(const exprt::operandst &values, const typet &field_type)
355359
{
356360
if(values.size() == 1)
357361
{
358362
return values[0];
359363
}
364+
// TODO: FOTIS: Just `or_exprt`?
360365
return multi_ary_exprt(ID_bitor, values, field_type);
361366
}
362367

src/goto-symex/shadow_memory_util.h

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,45 +112,67 @@ std::vector<std::pair<exprt, exprt>> get_shadow_dereference_candidates(
112112
const typet &lhs_type,
113113
bool &exact_match);
114114

115-
// TODO: doxygen
115+
/// Retrieves the value of the initialising expression.
116+
/// \param field_name The name of the field whose value type we want to query.
117+
/// \param state The symex_state within which the query is executed (the field's
118+
/// value is looked up).
119+
/// \returns The type of the value the field was initialised with (actually,
120+
/// the type of the value the field currently is associated with, but it's
121+
/// invariant since the declaration).
116122
const typet &
117123
get_field_init_type(const irep_idt &field_name, const goto_symex_statet &state);
118124

119-
// TODO: doxygen
125+
/// Given a pointer expression check to see if it can be a null pointer or an
126+
/// invalid object within value_set.
127+
/// \param address A pointer expressions that we are using as the query.
128+
/// \param value_set The search space for the query.
129+
/// \returns true if the object can be null or invalid in the value set, false
130+
/// otherwise.
120131
bool contains_null_or_invalid(
121132
const std::vector<exprt> &value_set,
122133
const exprt &address);
123134

124-
// TODO: doxygen
135+
/// Performs aggregation of the shadow memory field value over multiple cells
136+
/// for fields whose type is _Bool.
125137
exprt compute_or_over_cells(
126138
const exprt &expr,
127139
const typet &field_type,
128140
const namespacet &ns,
129141
const messaget &log,
130142
const bool is_union);
131143

132-
// TODO: doxygen
144+
/// Performs aggregation of the shadow memory field value over multiple cells
145+
/// for fields whose type is a signed/unsigned bitvector (where the value is
146+
/// arbitrary up until the max represented by the bitvector size).
133147
exprt compute_max_over_cells(
134148
const exprt &expr,
135149
const typet &field_type,
136150
const namespacet &ns,
137151
const messaget &log,
138152
const bool is_union);
139153

140-
// TODO: doxygen?
154+
/// Build an if-then-else chain from a vector containing pairs of expressions.
155+
/// \param conds_values Contains pairs <e1, e2>, where `e1` is going to be
156+
/// used as an antecedent for an if_expr, and `e2` is going to be used
157+
/// as the consequent.
158+
/// \returns An if_exprt of the form `if e1 then e2 else <if e3 then e4 else ...`
141159
exprt build_if_else_expr(
142160
const std::vector<std::pair<exprt, exprt>> &conds_values);
143161

144-
// TODO: improve?
145-
/// returns true if we attempt to set/get a field on a NULL pointer
162+
/// Checks if given expression is a null pointer.
163+
/// \returns true if expr is a a NULL pointer within value_set.
146164
bool set_field_check_null(
147165
const namespacet &ns,
148166
const messaget &log,
149167
const std::vector<exprt> &value_set,
150168
const exprt &expr);
151169

152-
// TODO: improve?
153-
/// Used for set_field and shadow memory copy
170+
/// Get shadow memory values for a given expression within a specified value
171+
/// set.
172+
/// \returns if potential values are present for that object inside the value
173+
/// set, then we get back an `if e1 then e2 else (if e3 else e4...` expression,
174+
/// where `e1`, `e3`, ... are guards (conditions) and `e2`, `e4`, etc are
175+
/// the possible values of the object within the value set.
154176
optionalt<exprt> get_shadow_memory(
155177
const exprt &expr,
156178
const std::vector<exprt> &value_set,

0 commit comments

Comments
 (0)