@@ -84,6 +84,19 @@ irep_idt custom_bitvector_domaint::object2id(const exprt &src)
84
84
return ' *' +id2string (op_id);
85
85
}
86
86
}
87
+ else if (src.id ()==ID_member)
88
+ {
89
+ const auto &m=to_member_expr (src);
90
+ const exprt &op=m.compound ();
91
+
92
+ irep_idt op_id=object2id (op);
93
+
94
+ if (op_id.empty ())
95
+ return irep_idt ();
96
+ else
97
+ return id2string (op_id)+' .' +
98
+ id2string (m.get_component_name ());
99
+ }
87
100
else if (src.id ()==ID_typecast)
88
101
return object2id (to_typecast_expr (src).op ());
89
102
else
@@ -209,6 +222,49 @@ std::set<exprt> custom_bitvector_analysist::aliases(
209
222
return std::set<exprt>();
210
223
}
211
224
225
+ void custom_bitvector_domaint::assign_struct_rec (
226
+ locationt from,
227
+ const exprt &lhs,
228
+ const exprt &rhs,
229
+ custom_bitvector_analysist &cba,
230
+ const namespacet &ns)
231
+ {
232
+ if (ns.follow (lhs.type ()).id ()==ID_struct)
233
+ {
234
+ const struct_typet &struct_type=
235
+ to_struct_type (ns.follow (lhs.type ()));
236
+
237
+ // assign member-by-member
238
+ for (const auto &c : struct_type.components ())
239
+ {
240
+ member_exprt lhs_member (lhs, c),
241
+ rhs_member (rhs, c);
242
+ assign_struct_rec (from, lhs_member, rhs_member, cba, ns);
243
+ }
244
+ }
245
+ else
246
+ {
247
+ // may alias other stuff
248
+ std::set<exprt> lhs_set=cba.aliases (lhs, from);
249
+
250
+ vectorst rhs_vectors=get_rhs (rhs);
251
+
252
+ for (const auto &lhs_alias : lhs_set)
253
+ {
254
+ assign_lhs (lhs_alias, rhs_vectors);
255
+ }
256
+
257
+ // is it a pointer?
258
+ if (lhs.type ().id ()==ID_pointer)
259
+ {
260
+ dereference_exprt lhs_deref (lhs);
261
+ dereference_exprt rhs_deref (rhs);
262
+ vectorst rhs_vectors=get_rhs (rhs_deref);
263
+ assign_lhs (lhs_deref, rhs_vectors);
264
+ }
265
+ }
266
+ }
267
+
212
268
void custom_bitvector_domaint::transform (
213
269
locationt from,
214
270
locationt to,
@@ -226,25 +282,7 @@ void custom_bitvector_domaint::transform(
226
282
case ASSIGN:
227
283
{
228
284
const code_assignt &code_assign=to_code_assign (instruction.code );
229
-
230
- // may alias other stuff
231
- std::set<exprt> lhs_set=cba.aliases (code_assign.lhs (), from);
232
-
233
- vectorst rhs_vectors=get_rhs (code_assign.rhs ());
234
-
235
- for (const auto &lhs : lhs_set)
236
- {
237
- assign_lhs (lhs, rhs_vectors);
238
- }
239
-
240
- // is it a pointer?
241
- if (code_assign.lhs ().type ().id ()==ID_pointer)
242
- {
243
- dereference_exprt lhs_deref (code_assign.lhs ());
244
- dereference_exprt rhs_deref (code_assign.rhs ());
245
- vectorst rhs_vectors=get_rhs (rhs_deref);
246
- assign_lhs (lhs_deref, rhs_vectors);
247
- }
285
+ assign_struct_rec (from, code_assign.lhs (), code_assign.rhs (), cba, ns);
248
286
}
249
287
break ;
250
288
0 commit comments