Skip to content

Commit dcd058a

Browse files
smowtonpeterschrammel
authored andcommitted
Comment and slightly reformat strip_casts
No functional changes
1 parent c6196c3 commit dcd058a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/pointer-analysis/value_set.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,26 @@ void value_sett::get_reference_set(
10621062
dest.push_back(to_expr(it));
10631063
}
10641064

1065+
/*******************************************************************\
1066+
1067+
Function: strip_casts
1068+
1069+
Inputs: `e`: expression to strip
1070+
`ns`: global namespace
1071+
`target_type_raw`: if in the course of stripping casts we
1072+
end up at an expression with this type, stop stripping.
1073+
1074+
Outputs: Side-effect on `e`: remove typecasts and address-of-first-
1075+
struct-member expressions until either we find an underlying
1076+
expression of type `target_type_raw`, or we run out of
1077+
strippable expressions.
1078+
1079+
Purpose: Cleanly cast `e` to a given type if possible, avoiding the
1080+
possibility of ever-expanding towers of typecasts (either
1081+
explict or via taking address of first member).
1082+
1083+
\*******************************************************************/
1084+
10651085
static void strip_casts(
10661086
exprt &e,
10671087
const namespacet &ns,
@@ -1083,6 +1103,7 @@ static void strip_casts(
10831103
}
10841104
else
10851105
return;
1106+
10861107
if(ns.follow(e.type())==target_type)
10871108
return;
10881109
}

0 commit comments

Comments
 (0)