[clang] [clang] Handle templated operators with reversed arguments (PR #69595)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 04:39:01 PDT 2023


================
@@ -7688,7 +7688,7 @@ bool Sema::CheckNonDependentConversions(
     QualType ParamType = ParamTypes[I + Offset];
     if (!ParamType->isDependentType()) {
       unsigned ConvIdx = PO == OverloadCandidateParamOrder::Reversed
-                             ? 0
+                             ? Args.size() - 1 - (ThisConversions + I)
----------------
ilya-biryukov wrote:

Thanks for clearing this up for me offline. After going through an example I finally got what was wrong here.
For reversed operators `Args.size()` is always 2. When `ThisConversions == 0` (i.e. non-methods), we were writing conversions for *both* arguments into `ConvIdx == 0`, after this change we correctly loop through both.
When `ThisConversions == 1`, both versions work the same.

Indeed, the tests you added already check this behavior. Thanks! Resolving this.

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


More information about the cfe-commits mailing list