@@ -57,7 +57,8 @@ value_sett::entryt *value_sett::find_entry(const value_sett::idt &id)
57
57
const value_sett::entryt *
58
58
value_sett::find_entry (const value_sett::idt &id) const
59
59
{
60
- return const_cast <value_sett *>(this )->find_entry (id);
60
+ auto found = values.find (id);
61
+ return found == values.end () ? nullptr : &found->second ;
61
62
}
62
63
63
64
value_sett::entryt &value_sett::get_entry (const entryt &e, const typet &type)
@@ -371,11 +372,16 @@ static std::string strip_first_field_from_suffix(
371
372
return suffix.substr (field.length () + 1 );
372
373
}
373
374
374
- value_sett::entryt *value_sett::get_entry_for_symbol (
375
+ template <class maybe_const_value_sett >
376
+ auto value_sett::get_entry_for_symbol (
377
+ maybe_const_value_sett &value_set,
375
378
const irep_idt identifier,
376
379
const typet &type,
377
380
const std::string &suffix,
378
- const namespacet &ns)
381
+ const namespacet &ns) ->
382
+ typename std::conditional<std::is_const<maybe_const_value_sett>::value,
383
+ const value_sett::entryt *,
384
+ value_sett::entryt *>::type
379
385
{
380
386
if (
381
387
type.id () != ID_pointer && type.id () != ID_signedbv &&
@@ -393,7 +399,7 @@ value_sett::entryt *value_sett::get_entry_for_symbol(
393
399
: type;
394
400
395
401
// look it up
396
- value_sett::entryt *entry = find_entry (id2string (identifier) + suffix);
402
+ auto *entry = value_set. find_entry (id2string (identifier) + suffix);
397
403
398
404
// try first component name as suffix if not yet found
399
405
if (
@@ -406,27 +412,37 @@ value_sett::entryt *value_sett::get_entry_for_symbol(
406
412
const irep_idt &first_component_name =
407
413
struct_union_type.components ().front ().get_name ();
408
414
409
- entry = find_entry (
415
+ entry = value_set. find_entry (
410
416
id2string (identifier) + " ." + id2string (first_component_name) + suffix);
411
417
}
412
418
413
419
if (!entry)
414
420
{
415
421
// not found? try without suffix
416
- entry = find_entry (identifier);
422
+ entry = value_set. find_entry (identifier);
417
423
}
418
424
419
425
return entry;
420
426
}
421
427
428
+ // Explicitly instantiate the two possible versions of the method above:
429
+
430
+ value_sett::entryt *value_sett::get_entry_for_symbol (
431
+ irep_idt identifier,
432
+ const typet &type,
433
+ const std::string &suffix,
434
+ const namespacet &ns)
435
+ {
436
+ return get_entry_for_symbol (*this , identifier, type, suffix, ns);
437
+ }
438
+
422
439
const value_sett::entryt *value_sett::get_entry_for_symbol (
423
- const irep_idt identifier,
440
+ irep_idt identifier,
424
441
const typet &type,
425
442
const std::string &suffix,
426
443
const namespacet &ns) const
427
444
{
428
- return const_cast <value_sett *>(this )->get_entry_for_symbol (
429
- identifier, type, suffix, ns);
445
+ return get_entry_for_symbol (*this , identifier, type, suffix, ns);
430
446
}
431
447
432
448
void value_sett::get_value_set_rec (
0 commit comments