@@ -18,39 +18,6 @@ Author: Diffblue Ltd.
18
18
#include < util/expr_util.h>
19
19
#include < util/suffix.h>
20
20
21
- // / Given an expression, attempt to find the underlying symbol it represents
22
- // / by skipping over type casts and removing balanced dereference/address_of
23
- // / operations
24
- optionalt<symbol_exprt>
25
- root_object (const exprt &lhs_expr, const symbol_tablet &symbol_table)
26
- {
27
- auto expr = skip_typecast (lhs_expr);
28
- int dereference_balance = 0 ;
29
- while (!can_cast_expr<symbol_exprt>(expr))
30
- {
31
- if (const auto deref = expr_try_dynamic_cast<dereference_exprt>(expr))
32
- {
33
- ++dereference_balance;
34
- expr = skip_typecast (deref->pointer ());
35
- }
36
- else if (
37
- const auto address_of = expr_try_dynamic_cast<address_of_exprt>(expr))
38
- {
39
- --dereference_balance;
40
- expr = skip_typecast (address_of->object ());
41
- }
42
- else
43
- {
44
- return {};
45
- }
46
- }
47
- if (dereference_balance != 0 )
48
- {
49
- return {};
50
- }
51
- return to_symbol_expr (expr);
52
- }
53
-
54
21
// / Expand value of a function to include all child codets
55
22
// / \param function_value: The value of the function (e.g. got by looking up
56
23
// / the function in the symbol table and getting the value)
@@ -139,7 +106,7 @@ require_goto_statements::find_struct_component_assignments(
139
106
ode.build (superclass_expr, ns);
140
107
if (
141
108
superclass_expr.get_component_name () == supercomponent_name &&
142
- root_object (ode.root_object (), symbol_table)-> get_identifier () ==
109
+ to_symbol_expr (ode.root_object ()). get_identifier () ==
143
110
structure_name)
144
111
{
145
112
if (
@@ -162,10 +129,13 @@ require_goto_statements::find_struct_component_assignments(
162
129
// - component name: \p component_name
163
130
// - operand (component of): symbol for \p structure_name
164
131
165
- const auto &root_object =
166
- ::root_object (member_expr.struct_op(), symbol_table);
132
+ object_descriptor_exprt ode;
133
+ const namespacet ns (symbol_table);
134
+ ode.build (member_expr, ns);
167
135
if (
168
- root_object && root_object->get_identifier () == structure_name &&
136
+ ode.root_object ().id () == ID_symbol &&
137
+ to_symbol_expr (ode.root_object ()).get_identifier () ==
138
+ structure_name &&
169
139
member_expr.get_component_name () == component_name)
170
140
{
171
141
if (
0 commit comments