@@ -10700,29 +10700,10 @@ bool clang::isBetterOverloadCandidate(
10700
10700
// -— F1 and F2 are non-template functions with the same
10701
10701
// parameter-type-lists, and F1 is more constrained than F2 [...],
10702
10702
if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
10703
- sameFunctionParameterTypeLists(S, Cand1, Cand2)) {
10704
- FunctionDecl *Function1 = Cand1.Function;
10705
- FunctionDecl *Function2 = Cand2.Function;
10706
- if (FunctionDecl *MF = Function1->getInstantiatedFromMemberFunction())
10707
- Function1 = MF;
10708
- if (FunctionDecl *MF = Function2->getInstantiatedFromMemberFunction())
10709
- Function2 = MF;
10710
-
10711
- const Expr *RC1 = Function1->getTrailingRequiresClause();
10712
- const Expr *RC2 = Function2->getTrailingRequiresClause();
10713
- if (RC1 && RC2) {
10714
- bool AtLeastAsConstrained1, AtLeastAsConstrained2;
10715
- if (S.IsAtLeastAsConstrained(Function1, RC1, Function2, RC2,
10716
- AtLeastAsConstrained1) ||
10717
- S.IsAtLeastAsConstrained(Function2, RC2, Function1, RC1,
10718
- AtLeastAsConstrained2))
10719
- return false;
10720
- if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
10721
- return AtLeastAsConstrained1;
10722
- } else if (RC1 || RC2) {
10723
- return RC1 != nullptr;
10724
- }
10725
- }
10703
+ sameFunctionParameterTypeLists(S, Cand1, Cand2) &&
10704
+ S.getMoreConstrainedFunction(Cand1.Function, Cand2.Function) ==
10705
+ Cand1.Function)
10706
+ return true;
10726
10707
10727
10708
// -- F1 is a constructor for a class D, F2 is a constructor for a base
10728
10709
// class B of D, and for all arguments the corresponding parameters of
@@ -13390,25 +13371,6 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &Pair) {
13390
13371
static_cast<int>(CUDA().IdentifyPreference(Caller, FD2));
13391
13372
};
13392
13373
13393
- auto CheckMoreConstrained = [&](FunctionDecl *FD1,
13394
- FunctionDecl *FD2) -> std::optional<bool> {
13395
- if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
13396
- FD1 = MF;
13397
- if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
13398
- FD2 = MF;
13399
- SmallVector<const Expr *, 1> AC1, AC2;
13400
- FD1->getAssociatedConstraints(AC1);
13401
- FD2->getAssociatedConstraints(AC2);
13402
- bool AtLeastAsConstrained1, AtLeastAsConstrained2;
13403
- if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
13404
- return std::nullopt;
13405
- if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
13406
- return std::nullopt;
13407
- if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
13408
- return std::nullopt;
13409
- return AtLeastAsConstrained1;
13410
- };
13411
-
13412
13374
// Don't use the AddressOfResolver because we're specifically looking for
13413
13375
// cases where we have one overload candidate that lacks
13414
13376
// enable_if/pass_object_size/...
@@ -13445,15 +13407,14 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &Pair) {
13445
13407
}
13446
13408
// FD has the same CUDA prefernece than Result. Continue check
13447
13409
// constraints.
13448
- std::optional<bool> MoreConstrainedThanPrevious =
13449
- CheckMoreConstrained(FD, Result);
13450
- if (!MoreConstrainedThanPrevious) {
13451
- IsResultAmbiguous = true;
13452
- AmbiguousDecls.push_back(FD);
13410
+ FunctionDecl *MoreConstrained = getMoreConstrainedFunction(FD, Result);
13411
+ if (MoreConstrained != FD) {
13412
+ if (!MoreConstrained) {
13413
+ IsResultAmbiguous = true;
13414
+ AmbiguousDecls.push_back(FD);
13415
+ }
13453
13416
continue;
13454
13417
}
13455
- if (!*MoreConstrainedThanPrevious)
13456
- continue;
13457
13418
// FD is more constrained - replace Result with it.
13458
13419
}
13459
13420
FoundBetter();
@@ -13472,7 +13433,7 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &Pair) {
13472
13433
// constraints.
13473
13434
if (getLangOpts().CUDA && CheckCUDAPreference(Skipped, Result) != 0)
13474
13435
continue;
13475
- if (!CheckMoreConstrained (Skipped, Result))
13436
+ if (!getMoreConstrainedFunction (Skipped, Result))
13476
13437
return nullptr;
13477
13438
}
13478
13439
Pair = DAP;
0 commit comments