@@ -51,6 +51,13 @@ bool value_sett::field_sensitive(
51
51
return ns.follow (type).id ()==ID_struct;
52
52
}
53
53
54
+ const value_sett::entryt *value_sett::find_entry (const value_sett::idt &id)
55
+ const
56
+ {
57
+ auto found = values.find (id);
58
+ return found == values.end () ? nullptr : &found->second ;
59
+ }
60
+
54
61
value_sett::entryt &value_sett::get_entry (
55
62
const entryt &e,
56
63
const typet &type,
@@ -429,31 +436,29 @@ void value_sett::get_value_set_rec(
429
436
expr_type.id ()==ID_array)
430
437
{
431
438
// look it up
432
- valuest::const_iterator v_it =
433
- values. find (id2string (identifier)+ suffix);
439
+ const entryt *entry =
440
+ find_entry (id2string (identifier) + suffix);
434
441
435
442
// try first component name as suffix if not yet found
436
- if (v_it==values.end () &&
437
- (expr_type.id ()==ID_struct ||
438
- expr_type.id ()==ID_union))
443
+ if (!entry && (expr_type.id () == ID_struct || expr_type.id () == ID_union))
439
444
{
440
445
const struct_union_typet &struct_union_type=
441
446
to_struct_union_type (expr_type);
442
447
443
448
const irep_idt &first_component_name =
444
449
struct_union_type.components ().front ().get_name ();
445
450
446
- v_it = values. find (
451
+ entry = find_entry (
447
452
id2string (identifier) + " ." + id2string (first_component_name) +
448
453
suffix);
449
454
}
450
455
451
456
// not found? try without suffix
452
- if (v_it==values. end () )
453
- v_it=values. find (identifier);
457
+ if (!entry )
458
+ entry = find_entry (identifier);
454
459
455
- if (v_it!=values. end () )
456
- make_union (dest, v_it-> second . object_map );
460
+ if (entry )
461
+ make_union (dest, entry-> object_map );
457
462
else
458
463
insert (dest, exprt (ID_unknown, original_type));
459
464
}
@@ -857,16 +862,16 @@ void value_sett::get_value_set_rec(
857
862
const std::string full_name=prefix+suffix;
858
863
859
864
// look it up
860
- valuest::const_iterator v_it=values. find (full_name);
865
+ const entryt *entry = find_entry (full_name);
861
866
862
867
// not found? try without suffix
863
- if (v_it==values. end () )
864
- v_it=values. find (prefix);
868
+ if (!entry )
869
+ entry = find_entry (prefix);
865
870
866
- if (v_it==values. end () )
871
+ if (!entry )
867
872
insert (dest, exprt (ID_unknown, original_type));
868
873
else
869
- make_union (dest, v_it-> second . object_map );
874
+ make_union (dest, entry-> object_map );
870
875
}
871
876
else if (expr.id ()==ID_byte_extract_little_endian ||
872
877
expr.id ()==ID_byte_extract_big_endian)
0 commit comments