@@ -367,6 +367,54 @@ static std::string strip_first_field_from_suffix(
367
367
return suffix.substr (field.length () + 1 );
368
368
}
369
369
370
+ const value_sett::entryt *value_sett::get_entry_for_symbol (
371
+ const irep_idt identifier,
372
+ const typet &type,
373
+ const std::string &suffix,
374
+ const namespacet &ns) const
375
+ {
376
+ if (
377
+ type.id () != ID_pointer && type.id () != ID_signedbv &&
378
+ type.id () != ID_unsignedbv && type.id () != ID_array &&
379
+ type.id () != ID_struct && type.id () != ID_struct_tag &&
380
+ type.id () != ID_union && type.id () != ID_union_tag)
381
+ {
382
+ return nullptr ;
383
+ }
384
+
385
+ const typet &followed_type = type.id () == ID_struct_tag
386
+ ? ns.follow_tag (to_struct_tag_type (type))
387
+ : type.id () == ID_union_tag
388
+ ? ns.follow_tag (to_union_tag_type (type))
389
+ : type;
390
+
391
+ // look it up
392
+ const value_sett::entryt *entry = find_entry (id2string (identifier) + suffix);
393
+
394
+ // try first component name as suffix if not yet found
395
+ if (
396
+ !entry &&
397
+ (followed_type.id () == ID_struct || followed_type.id () == ID_union))
398
+ {
399
+ const struct_union_typet &struct_union_type =
400
+ to_struct_union_type (followed_type);
401
+
402
+ const irep_idt &first_component_name =
403
+ struct_union_type.components ().front ().get_name ();
404
+
405
+ entry = find_entry (
406
+ id2string (identifier) + " ." + id2string (first_component_name) + suffix);
407
+ }
408
+
409
+ if (!entry)
410
+ {
411
+ // not found? try without suffix
412
+ entry = find_entry (identifier);
413
+ }
414
+
415
+ return entry;
416
+ }
417
+
370
418
void value_sett::get_value_set_rec (
371
419
const exprt &expr,
372
420
object_mapt &dest,
@@ -414,43 +462,11 @@ void value_sett::get_value_set_rec(
414
462
}
415
463
else if (expr.id ()==ID_symbol)
416
464
{
417
- irep_idt identifier=to_symbol_expr (expr).get_identifier ();
418
-
419
- // is it a pointer, integer, array or struct?
420
- if (expr_type.id ()==ID_pointer ||
421
- expr_type.id ()==ID_signedbv ||
422
- expr_type.id ()==ID_unsignedbv ||
423
- expr_type.id ()==ID_struct ||
424
- expr_type.id ()==ID_union ||
425
- expr_type.id ()==ID_array)
426
- {
427
- // look it up
428
- const entryt *entry =
429
- find_entry (id2string (identifier) + suffix);
430
-
431
- // try first component name as suffix if not yet found
432
- if (!entry && (expr_type.id () == ID_struct || expr_type.id () == ID_union))
433
- {
434
- const struct_union_typet &struct_union_type=
435
- to_struct_union_type (expr_type);
465
+ const entryt *entry = get_entry_for_symbol (
466
+ to_symbol_expr (expr).get_identifier (), expr_type, suffix, ns);
436
467
437
- const irep_idt &first_component_name =
438
- struct_union_type.components ().front ().get_name ();
439
-
440
- entry = find_entry (
441
- id2string (identifier) + " ." + id2string (first_component_name) +
442
- suffix);
443
- }
444
-
445
- // not found? try without suffix
446
- if (!entry)
447
- entry = find_entry (identifier);
448
-
449
- if (entry)
450
- make_union (dest, entry->object_map );
451
- else
452
- insert (dest, exprt (ID_unknown, original_type));
453
- }
468
+ if (entry)
469
+ make_union (dest, entry->object_map );
454
470
else
455
471
insert (dest, exprt (ID_unknown, original_type));
456
472
}
0 commit comments