@@ -22,17 +22,16 @@ Author: Peter Schrammel
2222#include < util/ssa_expr.h>
2323#include < util/std_expr.h>
2424
25- #include < langapi/language_util.h> // IWYU pragma: keep
2625
2726// TODO: change DEBUG_SM to DEBUG_SHADOW_MEMORY (it also appears in other files)
2827
2928irep_idt extract_field_name (const exprt &string_expr)
3029{
31- if (string_expr. id () == ID_typecast )
30+ if (can_cast_expr<typecast_exprt>(string_expr) )
3231 return extract_field_name (to_typecast_expr (string_expr).op ());
33- else if (string_expr. id () == ID_address_of )
32+ else if (can_cast_expr<address_of_exprt>(string_expr) )
3433 return extract_field_name (to_address_of_expr (string_expr).object ());
35- else if (string_expr. id () == ID_index )
34+ else if (can_cast_expr<index_exprt>(string_expr) )
3635 return extract_field_name (to_index_expr (string_expr).array ());
3736 else if (string_expr.id () == ID_string_constant)
3837 {
@@ -42,8 +41,8 @@ irep_idt extract_field_name(const exprt &string_expr)
4241 UNREACHABLE;
4342}
4443
45- // / If the given type is an array type, then remove the L2 level
46- // / renaming from its size.
44+ // / If the given type is an array type, then remove the L2 level renaming
45+ // / from its size.
4746// / \param type Type to be modified
4847static void remove_array_type_l2 (typet &type)
4948{
@@ -56,7 +55,7 @@ static void remove_array_type_l2(typet &type)
5655
5756exprt deref_expr (const exprt &expr)
5857{
59- if (expr. id () == ID_address_of )
58+ if (can_cast_expr<address_of_exprt>(expr) )
6059 {
6160 return to_address_of_expr (expr).object ();
6261 }
@@ -67,7 +66,7 @@ exprt deref_expr(const exprt &expr)
6766void clean_pointer_expr (exprt &expr, const typet &type)
6867{
6968 if (
70- type. id () == ID_array && expr. id () == ID_symbol &&
69+ can_cast_type<array_typet>(type) && can_cast_expr<symbol_exprt>(expr) &&
7170 to_array_type (type).size ().get_bool (ID_C_SSA_symbol))
7271 {
7372 remove_array_type_l2 (expr.type ());
@@ -80,15 +79,15 @@ void clean_pointer_expr(exprt &expr, const typet &type)
8079 expr = address_of_exprt (expr);
8180 expr.type () = pointer_type (char_type ());
8281 }
83- else if (expr. id () == ID_dereference )
82+ else if (can_cast_expr<dereference_exprt>(expr) )
8483 {
8584 expr = to_dereference_expr (expr).pointer ();
8685 }
8786 else
8887 {
8988 expr = address_of_exprt (expr);
9089 }
91- POSTCONDITION (expr.type (). id () == ID_pointer );
90+ POSTCONDITION (can_cast_type<pointer_typet>( expr.type ()) );
9291}
9392
9493void log_set_field (
@@ -691,7 +690,16 @@ static exprt get_matched_expr_cond(
691690 return expr_cond;
692691}
693692
694- // TODO: doxygen?
693+ // / Retrieve the shadow value a pointer expression may point to.
694+ // / \param shadow The shadow expression.
695+ // / \param matched_base_descriptor The base descriptor for the shadow object.
696+ // / \param expr The pointer expression.
697+ // / \param ns The namespace within which we're going to perform symbol lookups.
698+ // / \param log The message log to which we're going to print debugging messages,
699+ // / if debugging is set.
700+ // / \returns A `valuet` object denoting the dereferenced object within shadow
701+ // / memory, guarded by a appropriate condition (of the form
702+ // / pointer == &shadow_object).
695703static value_set_dereferencet::valuet get_shadow_dereference (
696704 const exprt &shadow,
697705 const object_descriptor_exprt &matched_base_descriptor,
0 commit comments