Skip to content

Commit b42bac8

Browse files
authored
Merge pull request #5012 from diffblue/opX-goto-cc
fix exprt::opX accesses in linker_script_merge
2 parents a4997f0 + 7bf94f1 commit b42bac8

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/goto-cc/linker_script_merge.cpp

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,45 +126,58 @@ linker_script_merget::linker_script_merget(
126126
{replacement_predicatet(
127127
"address of array's first member",
128128
[](const exprt &expr) -> const symbol_exprt & {
129-
return to_symbol_expr(expr.op0().op0());
129+
return to_symbol_expr(
130+
to_index_expr(to_address_of_expr(expr).object()).index());
130131
},
131132
[](const exprt &expr) {
132133
return expr.id() == ID_address_of &&
133134
expr.type().id() == ID_pointer &&
134135

135-
expr.op0().id() == ID_index &&
136-
expr.op0().type().id() == ID_unsignedbv &&
137-
138-
expr.op0().op0().id() == ID_symbol &&
139-
expr.op0().op0().type().id() == ID_array &&
140-
141-
expr.op0().op1().id() == ID_constant &&
142-
expr.op0().op1().type().id() == ID_signedbv;
136+
to_address_of_expr(expr).object().id() == ID_index &&
137+
to_address_of_expr(expr).object().type().id() ==
138+
ID_unsignedbv &&
139+
140+
to_index_expr(to_address_of_expr(expr).object())
141+
.array()
142+
.id() == ID_symbol &&
143+
to_index_expr(to_address_of_expr(expr).object())
144+
.array()
145+
.type()
146+
.id() == ID_array &&
147+
148+
to_index_expr(to_address_of_expr(expr).object())
149+
.index()
150+
.id() == ID_constant &&
151+
to_index_expr(to_address_of_expr(expr).object())
152+
.index()
153+
.type()
154+
.id() == ID_signedbv;
143155
}),
144156
replacement_predicatet(
145157
"address of array",
146158
[](const exprt &expr) -> const symbol_exprt & {
147-
return to_symbol_expr(expr.op0());
159+
return to_symbol_expr(to_address_of_expr(expr).object());
148160
},
149161
[](const exprt &expr) {
150162
return expr.id() == ID_address_of &&
151163
expr.type().id() == ID_pointer &&
152164

153-
expr.op0().id() == ID_symbol &&
154-
expr.op0().type().id() == ID_array;
165+
to_address_of_expr(expr).object().id() == ID_symbol &&
166+
to_address_of_expr(expr).object().type().id() == ID_array;
155167
}),
156168
replacement_predicatet(
157169
"address of struct",
158170
[](const exprt &expr) -> const symbol_exprt & {
159-
return to_symbol_expr(expr.op0());
171+
return to_symbol_expr(to_address_of_expr(expr).object());
160172
},
161173
[](const exprt &expr) {
162174
return expr.id() == ID_address_of &&
163175
expr.type().id() == ID_pointer &&
164176

165-
expr.op0().id() == ID_symbol &&
166-
(expr.op0().type().id() == ID_struct ||
167-
expr.op0().type().id() == ID_struct_tag);
177+
to_address_of_expr(expr).object().id() == ID_symbol &&
178+
(to_address_of_expr(expr).object().type().id() == ID_struct ||
179+
to_address_of_expr(expr).object().type().id() ==
180+
ID_struct_tag);
168181
}),
169182
replacement_predicatet(
170183
"array variable",

0 commit comments

Comments
 (0)