@@ -138,6 +138,9 @@ void log_value_set(
138138#endif
139139}
140140
141+ // / Log a match between an address and a value the value set. This version of
142+ // / the function reports more details, including the base address, the pointer
143+ // / and the shadow value.
141144void log_value_set_match (
142145 const namespacet &ns,
143146 const messaget &log,
@@ -185,6 +188,9 @@ void log_value_set_match(
185188#endif
186189}
187190
191+ // / Log trying out a match between an object and a (target) shadow address.
192+ // / @param shadowed_address The address for which we're currently attempting to
193+ // / match.
188194void log_try_shadow_address (
189195 const namespacet &ns,
190196 const messaget &log,
@@ -199,6 +205,9 @@ void log_try_shadow_address(
199205#endif
200206}
201207
208+ // / Generic logging function that will log depending on the configured
209+ // / verbosity. Will log a specific message given to it, along with an expression
210+ // / passed along to it.
202211void log_cond (
203212 const namespacet &ns,
204213 const messaget &log,
@@ -294,7 +303,9 @@ bool contains_null_or_invalid(
294303 return false ;
295304}
296305
297- // TODO: doxygen?
306+ // / Casts a given (float) bitvector expression to an unsigned bitvector.
307+ // / \param value The expression that we are to conditionally cast.
308+ // / \return An unsigned bitvector expression if eligible - `id` otherwise.
298309static exprt conditional_cast_floatbv_to_unsignedbv (const exprt &value)
299310{
300311 if (value.type ().id () != ID_floatbv)
@@ -307,7 +318,13 @@ static exprt conditional_cast_floatbv_to_unsignedbv(const exprt &value)
307318 unsignedbv_typet (to_bitvector_type (value.type ()).get_width ()));
308319}
309320
310- // TODO: doxygen?
321+ // / Extract byte-sized elements from the input bitvector-typed expression value
322+ // / and places them into the array values.
323+ // / \param value the bitvector typed expression to extract the bytes from
324+ // / \param type the type of the expression expr (it must be bitvector)
325+ // / \param field_type the type of the shadow memory
326+ // / \param values the vector where all the extracted bytes of value will be
327+ // / placed.
311328static void extract_bytes_of_bv (
312329 const exprt &value,
313330 const typet &type,
@@ -327,7 +344,16 @@ static void extract_bytes_of_bv(
327344 }
328345}
329346
330- // TODO: doxygen?
347+ // / Extract the components from the input expression value and places them into
348+ // / the array values.
349+ // / \param element the expression to extract the bytes from
350+ // / \param field_type the type of the shadow memory
351+ // / \param ns the namespace within which we're going to perform symbol lookups
352+ // / \param log the message log to which we're going to print debugging messages,
353+ // / if debugging is set
354+ // / \param is_union true if the expression element is part of a union
355+ // / \param values the vector where all the extracted components of element will
356+ // / be placed.
331357static void extract_bytes_of_expr (
332358 exprt element,
333359 const typet &field_type,
@@ -556,7 +582,6 @@ exprt compute_max_over_bytes(
556582 return max_expr;
557583}
558584
559- // TODO: doxygen?
560585exprt build_if_else_expr (
561586 const std::vector<std::pair<exprt, exprt>> &conds_values)
562587{
@@ -577,7 +602,12 @@ exprt build_if_else_expr(
577602 return result;
578603}
579604
580- // TODO: doxygen?
605+ // / @brief Checks given types (object type and shadow memory field type) for
606+ // / equality. We're inspecting only pointer types here - if the two types
607+ // / given are not pointer types, then we assume it to be vacuously true.
608+ // / @param expr_type The type of the real object.
609+ // / @param shadow_type The type of the shadow memory field's value.
610+ // / @return True if types equal, false otherwise.
581611static bool
582612are_types_compatible (const typet &expr_type, const typet &shadow_type)
583613{
@@ -607,9 +637,9 @@ are_types_compatible(const typet &expr_type, const typet &shadow_type)
607637 return true ;
608638}
609639
610- // TODO: doxygen?
611- // / We simplify &string_constant[0] to &string_constant to facilitate expression
640+ // / Simplify &string_constant[0] to &string_constant to facilitate expression
612641// / equality for exact matching.
642+ // / \note expression expr will be changed.
613643static void clean_string_constant (exprt &expr)
614644{
615645 const auto *index_expr = expr_try_dynamic_cast<index_exprt>(expr);
@@ -621,7 +651,10 @@ static void clean_string_constant(exprt &expr)
621651 }
622652}
623653
624- // TODO: doxygen?
654+ // / Flattens type of the form `pointer_type(array_type(element_type))` to
655+ // / `pointer_type(element_type)` and `pointer_type(string_constant_type)` to
656+ // / `pointer_type(char)`.
657+ // / \note type `type` will be changed.
625658static void adjust_array_types (typet &type)
626659{
627660 auto *pointer_type = type_try_dynamic_cast<pointer_typet>(type);
@@ -641,7 +674,12 @@ static void adjust_array_types(typet &type)
641674 }
642675}
643676
644- // TODO: doxygen?
677+ // / Function that compares the two arguments shadowed_address and
678+ // / matched_base_address, simplifies the comparison expression and if the lhs
679+ // / and rhs are structurally identical returns true, otherwise returns the
680+ // / comparison.
681+ // / \return the comparison expression of shadowed_address and
682+ // / matched_base_address (or a true_exprt if identical modulo simplification).
645683static exprt get_matched_base_cond (
646684 const exprt &shadowed_address,
647685 const exprt &matched_base_address,
@@ -676,7 +714,11 @@ static exprt get_matched_base_cond(
676714 return base_cond;
677715}
678716
679- // TODO: doxygen?
717+ // / Function that compares the two arguments dereference_pointer and expr,
718+ // / simplifies the comparison expression and if the lhs and rhs are structurally
719+ // / identical returns true, otherwise returns the comparison.
720+ // / \return the comparison expression of dereference_pointer and expr (or a
721+ // / true_exprt if identical modulo simplification).
680722static exprt get_matched_expr_cond (
681723 const exprt &dereference_pointer,
682724 const exprt &expr,
@@ -738,7 +780,6 @@ static value_set_dereferencet::valuet get_shadow_dereference(
738780 return shadow_dereference;
739781}
740782
741- // TODO: doxygen?
742783/* foreach shadowed_address in SM:
743784 * if(incompatible(shadow.object, object)) continue; // Type incompatibility
744785 * base_match = object == shadow_object; // Do the base obj match the SM obj
@@ -886,7 +927,6 @@ std::vector<std::pair<exprt, exprt>> get_shadow_dereference_candidates(
886927 return result;
887928}
888929
889- // TODO: doxygen?
890930// Unfortunately.
891931static object_descriptor_exprt
892932normalize (const object_descriptor_exprt &expr, const namespacet &ns)
0 commit comments