[clang] [Clang] Implement CWG2918 'Consideration of constraints for address of overloaded function' (PR #127773)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 19 12:52:59 PST 2025
================
@@ -13252,6 +13273,33 @@ class AddressOfFunctionResolver {
}
}
+ void EliminateLessPartialOrderingConstrainedMatches() {
+ // C++ [over.over]p5:
+ // [...] Any given non-template function F0 is eliminated if the set
+ // contains a second non-template function that is more
+ // partial-ordering-constrained than F0. [...]
+ assert(Matches[0].second->getPrimaryTemplate() == nullptr &&
+ "Call EliminateAllTemplateMatches() first");
+ SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
+ Results.push_back(Matches[0]);
+ for (unsigned I = 1, N = Matches.size(); I < N; ++I) {
+ assert(Matches[I].second->getPrimaryTemplate() == nullptr);
+ FunctionDecl *F = getMorePartialOrderingConstrained(
+ S, Matches[I].second, Results[0].second,
+ /*IsFn1Reversed=*/false,
+ /*IsFn2Reversed=*/false);
+ if (!F) {
+ Results.push_back(Matches[I]);
+ continue;
+ }
+ if (F == Matches[I].second) {
+ Results.clear();
+ Results.push_back(Matches[I]);
+ }
+ }
+ std::swap(Matches, Results);
----------------
mizvekov wrote:
Does this work if there are pairs of functions in the set which are not more constrained than the other both ways?
Do we have existing tests which cover that?
https://github.com/llvm/llvm-project/pull/127773
More information about the cfe-commits
mailing list