<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 1, 2014 at 3:26 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, May 1, 2014 at 2:15 PM, Kaelyn Takata <<a href="mailto:rikka@google.com">rikka@google.com</a>> wrote:<br>
</div><div><div class="h5">> Author: rikka<br>
> Date: Thu May 1 16:15:24 2014<br>
> New Revision: 207796<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207796&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207796&view=rev</a><br>
> Log:<br>
> When sorting overload candidates, sort arity mismatches in ascending<br>
> order by the number of missing or extra parameters. This is useful if<br>
> there are more than a few overload candidates with arity mismatches,<br>
> particularly in the presence of -fshow-overloads=best.<br>
><br>
> Modified:<br>
> cfe/trunk/lib/Sema/SemaOverload.cpp<br>
> cfe/trunk/test/Misc/error-limit-multiple-notes.cpp<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=207796&r1=207795&r2=207796&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=207796&r1=207795&r2=207796&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu May 1 16:15:24 2014<br>
> @@ -9229,7 +9229,10 @@ static unsigned RankDeductionFailure(con<br>
><br>
> struct CompareOverloadCandidatesForDisplay {<br>
> Sema &S;<br>
> - CompareOverloadCandidatesForDisplay(Sema &S) : S(S) {}<br>
> + size_t NumArgs;<br>
> +<br>
> + CompareOverloadCandidatesForDisplay(Sema &S, size_t nArgs)<br>
> + : S(S), NumArgs(nArgs) {}<br>
><br>
> bool operator()(const OverloadCandidate *L,<br>
> const OverloadCandidate *R) {<br>
> @@ -9254,8 +9257,18 @@ struct CompareOverloadCandidatesForDispl<br>
> if (!L->Viable) {<br>
> // 1. Arity mismatches come after other candidates.<br>
> if (L->FailureKind == ovl_fail_too_many_arguments ||<br>
> - L->FailureKind == ovl_fail_too_few_arguments)<br>
> + L->FailureKind == ovl_fail_too_few_arguments) {<br>
> + if (R->FailureKind == ovl_fail_too_many_arguments ||<br>
> + R->FailureKind == ovl_fail_too_few_arguments) {<br>
> + int LDist = abs(L->Function->getNumParams() - NumArgs);<br>
> + int RDist = abs(R->Function->getNumParams() - NumArgs);<br>
> + if (LDist == RDist)<br>
> + return L->FailureKind == ovl_fail_too_many_arguments &&<br>
> + R->FailureKind == ovl_fail_too_few_arguments;<br>
> + return LDist < RDist;<br>
> + }<br>
> return false;<br>
> + }<br>
> if (R->FailureKind == ovl_fail_too_many_arguments ||<br>
> R->FailureKind == ovl_fail_too_few_arguments)<br>
> return true;<br>
> @@ -9442,7 +9455,7 @@ void OverloadCandidateSet::NoteCandidate<br>
> }<br>
><br>
> std::sort(Cands.begin(), Cands.end(),<br>
> - CompareOverloadCandidatesForDisplay(S));<br>
> + CompareOverloadCandidatesForDisplay(S, Args.size()));<br>
><br>
> bool ReportedAmbiguousConversions = false;<br>
><br>
><br>
> Modified: cfe/trunk/test/Misc/error-limit-multiple-notes.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/error-limit-multiple-notes.cpp?rev=207796&r1=207795&r2=207796&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/error-limit-multiple-notes.cpp?rev=207796&r1=207795&r2=207796&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/Misc/error-limit-multiple-notes.cpp (original)<br>
> +++ cfe/trunk/test/Misc/error-limit-multiple-notes.cpp Thu May 1 16:15:24 2014<br>
> @@ -4,20 +4,22 @@<br>
> void foo(int);<br>
> void foo(double);<br>
> void foo(int, int);<br>
> +void foo(int, int, int, int);<br>
><br>
> int main()<br>
> {<br>
> - foo();<br>
> + foo(1, 2, 3);<br>
> }<br>
><br>
> // error and note suppressed by error-limit<br>
> struct s1{};<br>
> struct s1{};<br>
><br>
> -// CHECK: 10:5: error: no matching function for call to 'foo'<br>
> -// CHECK: 6:6: note: candidate function not viable: requires 2 arguments, but 0 were provided<br>
> -// CHECK: 5:6: note: candidate function not viable: requires 1 argument, but 0 were provided<br>
> -// CHECK: 4:6: note: candidate function not viable: requires 1 argument, but 0 were provided<br>
> +// CHECK: 11:5: error: no matching function for call to 'foo'<br>
> +// CHECK: 6:6: note: candidate function not viable: requires 2 arguments, but 3 were provided<br>
> +// CHECK: 7:6: note: candidate function not viable: requires 4 arguments, but 3 were provided<br>
> +// CHECK: 5:6: note: candidate function not viable: requires 1 argument, but 3 were provided<br>
> +// CHECK: 4:6: note: candidate function not viable: requires 1 argument, but 3 were provided<br>
<br>
</div></div>Would it be appropriate/worthwhile adding some cases where there are<br>
the same number of arguments but they're of different types? Or in<br>
that case do we not show the other candidates at all?<br></blockquote><div><br></div><div>What exactly do you mean by "same number of arguments but different types"? If you meant that a candidate accepts the right number of arguments but the types are wrong, they are already sorted before any arity mismatches. Also, there are already two one-argument candidates that have different argument types.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> // CHECK: fatal error: too many errors emitted, stopping now<br>
> -// CHECK-NOT: 15:8: error: redefinition of 's1'<br>
> -// CHECK-NOT: 14:8: note: previous definition is here<br>
> +// CHECK-NOT: 16:8: error: redefinition of 's1'<br>
> +// CHECK-NOT: 15:8: note: previous definition is here<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>