@@ -40,25 +40,6 @@ void local_value_sett::make_union_adjusting_evs_types(
40
40
}
41
41
}
42
42
43
- std::pair<value_sett::valuest::iterator, bool >
44
- local_value_sett::init_external_value_set (const external_value_set_exprt &evse)
45
- {
46
- PRECONDITION (!evse.access_path_entries ().empty ());
47
- const auto &apback=evse.access_path_entries ().back ();
48
- std::string basename=evse.get_access_path_basename (apback.declared_on_type ());
49
- std::string access_path_suffix=evse.get_access_path_suffix ();
50
- std::string entryname=basename+access_path_suffix;
51
-
52
- entryt entry (basename, access_path_suffix, apback.declared_on_type (), evse);
53
-
54
- auto insert_result=values.insert (std::make_pair (irep_idt (entryname), entry));
55
-
56
- if (insert_result.second )
57
- insert (insert_result.first ->second .object_map , evse);
58
-
59
- return insert_result;
60
- }
61
-
62
43
// / Builds a version of expr suitable for alias-comparison
63
44
// / \param expr: The expression to be converted to the alias-uniform structure
64
45
// / \return expr without information which is irrelevant to alias-comparison
@@ -282,11 +263,27 @@ void local_value_sett::get_value_set_rec(
282
263
new_entry, external_value_set_typet::PER_FIELD);
283
264
new_ext_set.type ()=field_type.subtype ();
284
265
285
- // TODO: figure out how to do this sort of on-demand-insert
286
- // without such ugly const hacking:
287
- auto insert_result=
288
- (const_cast <local_value_sett *>(this ))->
289
- init_external_value_set (new_ext_set);
266
+ std::string basename =
267
+ new_ext_set.get_access_path_basename (declared_on_type);
268
+ std::string entryname = basename + access_path_suffix;
269
+
270
+ entryt entry (
271
+ basename, access_path_suffix, declared_on_type, new_ext_set);
272
+
273
+ // / If there is already an entry for this EVS then find it, otherwise
274
+ // / create a new entry for it
275
+ // / TODO: figure out how to do this sort of on-demand-insert
276
+ // / without such ugly const hacking:
277
+ auto insert_result =
278
+ (const_cast <local_value_sett *>(this ))
279
+ ->values .insert (std::make_pair (irep_idt (entryname), entry));
280
+
281
+ // / If we've just created a new entry then populate the object map
282
+ // / with an initializer EVS
283
+ if (insert_result.second )
284
+ insert (
285
+ insert_result.first ->second .object_map ,
286
+ new_ext_set.as_initializer ());
290
287
291
288
make_union (dest, insert_result.first ->second .object_map );
292
289
}
@@ -309,13 +306,21 @@ void local_value_sett::get_value_set_rec(
309
306
{
310
307
new_ext_set.type ()=field_type.subtype ();
311
308
312
- // TODO: figure out how to do this sort of on-demand-insert
313
- // without such ugly const hacking:
314
- auto insert_result=
315
- (const_cast <local_value_sett *>(this ))->
316
- init_external_value_set (new_ext_set);
317
-
318
- make_union (dest, insert_result.first ->second .object_map );
309
+ declared_on_type =
310
+ external_value_set_exprt::get_precise_evs_irep_id ();
311
+ std::string basename =
312
+ new_ext_set.get_access_path_basename (declared_on_type);
313
+ access_path_suffix = new_ext_set.get_access_path_suffix ();
314
+ std::string entryname = basename + access_path_suffix;
315
+
316
+ const auto it = values.find (entryname);
317
+
318
+ // / If an entry already exists then use the values in the object
319
+ // / map, otherwise do not create an entry and use the EVS
320
+ if (it != values.end ())
321
+ make_union (dest, it->second .object_map );
322
+ else
323
+ insert (dest, new_ext_set);
319
324
}
320
325
}
321
326
}
@@ -582,7 +587,7 @@ void local_value_sett::assign_rec(
582
587
if (insert_result.second && field_type.id ()==ID_pointer)
583
588
{
584
589
new_ext_set.type ()=field_type.subtype ();
585
- insert (lhs_entry.object_map , new_ext_set);
590
+ insert (lhs_entry.object_map , new_ext_set. as_initializer () );
586
591
}
587
592
588
593
make_union (lhs_entry.object_map , values_rhs);
@@ -608,7 +613,10 @@ void local_value_sett::assign_rec(
608
613
std::string entryname=basename+access_path_suffix;
609
614
610
615
entryt entry (
611
- basename, access_path_suffix, declared_on_type, new_ext_set);
616
+ basename,
617
+ access_path_suffix,
618
+ external_value_set_exprt::get_precise_evs_irep_id (),
619
+ new_ext_set);
612
620
613
621
auto insert_result=const_cast <valuest &>(values).
614
622
insert (std::make_pair (irep_idt (entryname), entry));
0 commit comments