@@ -7685,7 +7685,7 @@ bool Sema::CheckNonDependentConversions(
7685
7685
QualType ParamType = ParamTypes[I + Offset];
7686
7686
if (!ParamType->isDependentType()) {
7687
7687
unsigned ConvIdx = PO == OverloadCandidateParamOrder::Reversed
7688
- ? Args.size() - 1 - (ThisConversions + I)
7688
+ ? 0
7689
7689
: (ThisConversions + I);
7690
7690
Conversions[ConvIdx]
7691
7691
= TryCopyInitialization(*this, Args[I], ParamType,
@@ -10082,19 +10082,11 @@ getImplicitObjectParamType(ASTContext &Context, const FunctionDecl *F) {
10082
10082
return M->getFunctionObjectParameterReferenceType();
10083
10083
}
10084
10084
10085
- // As a Clang extension, allow ambiguity among F1 and F2 if they represent
10086
- // represent the same entity.
10087
- static bool allowAmbiguity(ASTContext &Context, const FunctionDecl *F1,
10088
- const FunctionDecl *F2) {
10085
+ static bool haveSameParameterTypes(ASTContext &Context, const FunctionDecl *F1,
10086
+ const FunctionDecl *F2) {
10089
10087
if (declaresSameEntity(F1, F2))
10090
10088
return true;
10091
- if (F1->isTemplateInstantiation() && F2->isTemplateInstantiation() &&
10092
- declaresSameEntity(F1->getPrimaryTemplate(), F2->getPrimaryTemplate())) {
10093
- return true;
10094
- }
10095
- // TODO: It is not clear whether comparing parameters is necessary (i.e.
10096
- // different functions with same params). Consider removing this (as no test
10097
- // fail w/o it).
10089
+
10098
10090
auto NextParam = [&](const FunctionDecl *F, unsigned &I, bool First) {
10099
10091
if (First) {
10100
10092
if (std::optional<QualType> T = getImplicitObjectParamType(Context, F))
@@ -10279,14 +10271,14 @@ bool clang::isBetterOverloadCandidate(
10279
10271
case ImplicitConversionSequence::Worse:
10280
10272
if (Cand1.Function && Cand2.Function &&
10281
10273
Cand1.isReversed() != Cand2.isReversed() &&
10282
- allowAmbiguity (S.Context, Cand1.Function, Cand2.Function)) {
10274
+ haveSameParameterTypes (S.Context, Cand1.Function, Cand2.Function)) {
10283
10275
// Work around large-scale breakage caused by considering reversed
10284
10276
// forms of operator== in C++20:
10285
10277
//
10286
- // When comparing a function against a reversed function, if we have a
10287
- // better conversion for one argument and a worse conversion for the
10288
- // other, the implicit conversion sequences are treated as being equally
10289
- // good.
10278
+ // When comparing a function against a reversed function with the same
10279
+ // parameter types, if we have a better conversion for one argument and
10280
+ // a worse conversion for the other, the implicit conversion sequences
10281
+ // are treated as being equally good.
10290
10282
//
10291
10283
// This prevents a comparison function from being considered ambiguous
10292
10284
// with a reversed form that is written in the same way.
@@ -14457,7 +14449,7 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
14457
14449
llvm::SmallVector<FunctionDecl*, 4> AmbiguousWith;
14458
14450
for (OverloadCandidate &Cand : CandidateSet) {
14459
14451
if (Cand.Viable && Cand.Function && Cand.isReversed() &&
14460
- allowAmbiguity (Context, Cand.Function, FnDecl)) {
14452
+ haveSameParameterTypes (Context, Cand.Function, FnDecl)) {
14461
14453
for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
14462
14454
if (CompareImplicitConversionSequences(
14463
14455
*this, OpLoc, Cand.Conversions[ArgIdx],
0 commit comments