@@ -484,54 +484,47 @@ void cpp_typecheck_resolvet::disambiguate_functions(
484
484
}
485
485
}
486
486
487
- identifiers .clear ();
487
+ old_identifiers .clear ();
488
488
489
489
// put in the top ones
490
490
if (!distance_map.empty ())
491
491
{
492
- std::size_t distance=distance_map.begin ()->first ;
493
-
494
- for (std::multimap<std::size_t , exprt>::const_iterator
495
- it=distance_map.begin ();
496
- it!=distance_map.end () && it->first ==distance;
497
- it++)
498
- identifiers.push_back (it->second );
492
+ auto range=distance_map.equal_range (distance_map.begin ()->first );
493
+ for (auto it=range.first ; it!=range.second ; ++it)
494
+ old_identifiers.push_back (it->second );
499
495
}
500
496
501
- if (identifiers .size ()>1 && fargs.in_use )
497
+ if (old_identifiers .size ()>1 && fargs.in_use )
502
498
{
503
499
// try to further disambiguate functions
504
500
505
- for (resolve_identifierst::iterator
506
- it1=identifiers .begin ();
507
- it1!=identifiers .end ();
508
- it1++ )
501
+ for (resolve_identifierst::const_iterator
502
+ old_it=old_identifiers .begin ();
503
+ old_it!=old_identifiers .end ();
504
+ ++old_it )
509
505
{
510
- if (it1->type ().id ()!=ID_code)
506
+ #if 0
507
+ std::cout << "I1: " << old_it->get(ID_identifier) << '\n';
508
+ #endif
509
+
510
+ if (old_it->type ().id ()!=ID_code)
511
+ {
512
+ identifiers.push_back (*old_it);
511
513
continue ;
514
+ }
512
515
513
516
const code_typet &f1=
514
- to_code_type (it1 ->type ());
517
+ to_code_type (old_it ->type ());
515
518
516
- for (resolve_identifierst::iterator it2=
517
- identifiers.begin ();
518
- it2!=identifiers.end ();
519
- ) // no it2++
519
+ for (resolve_identifierst::const_iterator resolve_it=old_it+1 ;
520
+ resolve_it!=old_identifiers.end ();
521
+ ++resolve_it)
520
522
{
521
- if (it1 == it2)
522
- {
523
- it2++;
524
- continue ;
525
- }
526
-
527
- if (it2->type ().id ()!=ID_code)
528
- {
529
- it2++;
523
+ if (resolve_it->type ().id ()!=ID_code)
530
524
continue ;
531
- }
532
525
533
526
const code_typet &f2 =
534
- to_code_type (it2 ->type ());
527
+ to_code_type (resolve_it ->type ());
535
528
536
529
// TODO: may fail when using ellipsis
537
530
assert (f1.parameters ().size () == f2.parameters ().size ());
@@ -577,20 +570,24 @@ void cpp_typecheck_resolvet::disambiguate_functions(
577
570
{
578
571
f2_better=false ;
579
572
}
580
- else if (f2_better && cpp_typecheck.subtype_typecast (struct2, struct1))
573
+ else if (f2_better &&
574
+ cpp_typecheck.subtype_typecast (struct2, struct1))
581
575
{
582
576
f1_better=false ;
583
577
}
584
578
}
585
579
586
- resolve_identifierst::iterator prev_it=it2;
587
- it2++;
588
-
589
- if (f1_better && !f2_better)
590
- identifiers.erase (prev_it);
580
+ if (!f1_better || f2_better)
581
+ identifiers.push_back (*resolve_it);
591
582
}
592
583
}
593
584
}
585
+ else
586
+ {
587
+ identifiers.swap (old_identifiers);
588
+ }
589
+
590
+ remove_duplicates (identifiers);
594
591
}
595
592
596
593
void cpp_typecheck_resolvet::make_constructors (
@@ -935,7 +932,9 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope(
935
932
id_set);
936
933
937
934
#ifdef DEBUG
938
- std::cout << " S: " << cpp_typecheck.cpp_scopes .current_scope ().identifier << std::endl;
935
+ std::cout << " S: "
936
+ << cpp_typecheck.cpp_scopes .current_scope ().identifier
937
+ << std::endl;
939
938
cpp_typecheck.cpp_scopes .current_scope ().print (std::cout);
940
939
std::cout << " X: " << id_set.size () <<std::endl;
941
940
#endif
@@ -1418,7 +1417,8 @@ exprt cpp_typecheck_resolvet::resolve(
1418
1417
std::cout << " base name: " << base_name << std::endl;
1419
1418
std::cout << " template args: " << template_args << std::endl;
1420
1419
std::cout << " original-scope: " << original_scope->prefix << std::endl;
1421
- std::cout << " scope: " << cpp_typecheck.cpp_scopes .current_scope ().prefix << std::endl;
1420
+ std::cout << " scope: "
1421
+ << cpp_typecheck.cpp_scopes .current_scope ().prefix << std::endl;
1422
1422
#endif
1423
1423
1424
1424
const source_locationt &source_location=cpp_name.source_location ();
@@ -1610,8 +1610,8 @@ exprt cpp_typecheck_resolvet::resolve(
1610
1610
std::cout << "\n";
1611
1611
#endif
1612
1612
}
1613
-
1614
- remove_duplicates (new_identifiers);
1613
+ else
1614
+ remove_duplicates (new_identifiers);
1615
1615
1616
1616
#if 0
1617
1617
std::cout << "P4 " << base_name << " " << new_identifiers.size() << "\n";
0 commit comments