@@ -463,54 +463,44 @@ void cpp_typecheck_resolvet::disambiguate_functions(
463
463
}
464
464
}
465
465
466
- identifiers .clear ();
466
+ old_identifiers .clear ();
467
467
468
468
// put in the top ones
469
469
if (!distance_map.empty ())
470
470
{
471
- std::size_t distance=distance_map.begin ()->first ;
472
-
473
- for (std::multimap<std::size_t , exprt>::const_iterator
474
- it=distance_map.begin ();
475
- it!=distance_map.end () && it->first ==distance;
476
- it++)
477
- identifiers.push_back (it->second );
471
+ auto range = distance_map.equal_range (distance_map.begin ()->first );
472
+ for (auto it = range.first ; it != range.second ; ++it)
473
+ old_identifiers.push_back (it->second );
478
474
}
479
475
480
- if (identifiers .size ()> 1 && fargs.in_use )
476
+ if (old_identifiers .size () > 1 && fargs.in_use )
481
477
{
482
478
// try to further disambiguate functions
483
479
484
- for (resolve_identifierst::iterator
485
- it1=identifiers.begin ();
486
- it1!=identifiers.end ();
487
- it1++)
480
+ for (resolve_identifierst::const_iterator old_it = old_identifiers.begin ();
481
+ old_it != old_identifiers.end ();
482
+ ++old_it)
488
483
{
489
- if (it1->type ().id ()!=ID_code)
484
+ #if 0
485
+ std::cout << "I1: " << old_it->get(ID_identifier) << '\n';
486
+ #endif
487
+
488
+ if (old_it->type ().id () != ID_code)
489
+ {
490
+ identifiers.push_back (*old_it);
490
491
continue ;
492
+ }
491
493
492
- const code_typet &f1=
493
- to_code_type (it1->type ());
494
+ const code_typet &f1 = to_code_type (old_it->type ());
494
495
495
- for (resolve_identifierst::iterator it2=
496
- identifiers.begin ();
497
- it2!=identifiers.end ();
498
- ) // no it2++
496
+ for (resolve_identifierst::const_iterator resolve_it = old_it + 1 ;
497
+ resolve_it != old_identifiers.end ();
498
+ ++resolve_it)
499
499
{
500
- if (it1 == it2)
501
- {
502
- it2++;
503
- continue ;
504
- }
505
-
506
- if (it2->type ().id ()!=ID_code)
507
- {
508
- it2++;
500
+ if (resolve_it->type ().id () != ID_code)
509
501
continue ;
510
- }
511
502
512
- const code_typet &f2 =
513
- to_code_type (it2->type ());
503
+ const code_typet &f2 = to_code_type (resolve_it->type ());
514
504
515
505
// TODO: may fail when using ellipsis
516
506
assert (f1.parameters ().size () == f2.parameters ().size ());
@@ -562,14 +552,17 @@ void cpp_typecheck_resolvet::disambiguate_functions(
562
552
}
563
553
}
564
554
565
- resolve_identifierst::iterator prev_it=it2;
566
- it2++;
567
-
568
- if (f1_better && !f2_better)
569
- identifiers.erase (prev_it);
555
+ if (!f1_better || f2_better)
556
+ identifiers.push_back (*resolve_it);
570
557
}
571
558
}
572
559
}
560
+ else
561
+ {
562
+ identifiers.swap (old_identifiers);
563
+ }
564
+
565
+ remove_duplicates (identifiers);
573
566
}
574
567
575
568
void cpp_typecheck_resolvet::make_constructors (
@@ -1566,10 +1559,10 @@ exprt cpp_typecheck_resolvet::resolve(
1566
1559
std::cout << "\n";
1567
1560
#endif
1568
1561
}
1562
+ else
1563
+ remove_duplicates (new_identifiers);
1569
1564
1570
- remove_duplicates (new_identifiers);
1571
-
1572
- #if 0
1565
+ #if 0
1573
1566
std::cout << "P4 " << base_name << " " << new_identifiers.size() << "\n";
1574
1567
show_identifiers(base_name, new_identifiers, std::cout);
1575
1568
std::cout << "\n";
0 commit comments