[clang] [Clang][Sema] Fix last argument not being used when comparing function template specializations when one has an explicit object argument (PR #92263)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 03:00:49 PDT 2024


================
@@ -5591,7 +5592,11 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
                                               IsRValRef1);
       Args2.push_back(Obj2Ty);
     }
-    size_t NumComparedArguments = NumCallArguments1 + ShouldConvert1;
+    size_t NumComparedArguments = NumCallArguments1;
+    // Either added an argument above or the prototype includes an explicit
+    // object argument we need to count
+    if (Method1)
+      ++NumComparedArguments;
----------------
MitalAshok wrote:

@mizvekov It would look something like this: b19a252f50e3b6d5dd50b0e51ec2865bb83fd5c9

But I think it's more error-prone because instead of `+1` in one place, it's sometimes a `+1` in all the places `ExplicitCallArguments` is set

https://github.com/llvm/llvm-project/pull/92263


More information about the cfe-commits mailing list