<div class="gmail_quote">On Fri, Sep 9, 2011 at 10:33 AM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.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="im"><br>
On Sep 8, 2011, at 4:43 PM, Kaelyn Uhrain wrote:<br>
<br>
> Given a file tmp.cpp containing:<br>
><br>
</div>> [snip example]<br>
<div class="im">><br>
> When Clang emits the error about not finding a match for that call to f because exit is an overloaded function, Clang currently emits notes for all of the function template candidates in lexical order, to where the "closest" failing match is the 6th note of 9 with 3 candidates that require a different number of arguments listed before it:<br>
><br>
</div>> [snip example]<br>
<div class="im">><br>
><br>
> This small patch adds rankings to the different types of template deduction failure (all of the OverloadCandidates above have a base FailureKind of ovl_fail_bad_deduction), so that e.g. a candidate where a template argument could not be inferred is listed before a candidate that requires the wrong number of arguments. So for the above code example, the output becomes:<br>
><br>
</div>> [snip much-improved example]<br>
<div class="im">><br>
> While the text of the note still isn't particularly useful for figuring out what failed, it at least gives a little better clue as to where the problem lies (in this example, the problem is rooted in there being two different single-argument declarations of "exit"). Feedback is both welcome and desired, especially on the ranking of the different types of deduction failures.<br>
<br>
<br>
</div>I like this a lot! We could bike-shed on the specific rankings a lot, so I'll just make a few comments about the ranking:<br>
<br>
- TDK_InvalidExplicitArguments should, IMO, have a fairly poor ranking (4 or 5), because users are being very explicit about these arguments and the you generally have to be *very* wrong for template arguments to not match their template parameters (e.g., providing an expression where a type was expected)<br>
</blockquote><div><br>I moved TDK_InvalidExplicitArguments to rank 5 and made TDK_Too*Arguments rank 6 since I feel it's slightly more likely that someone gave the wrong argument to a template than to have the wrong number of arguments (with candidates needing the wrong number of arguments being a more common case, especially candidates that are way way out in left field).<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
- I suggest that TDK_SubstitutionFailure and TDK_NonDeducedMismatch should move up to rank 3, because these can often mean some little failure at the call site<br></blockquote><div><br>Done!<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
+ default:<br>
+ return UINT_MAX;<br>
+ }<br>
<br>
Why do we need a default here?<br></blockquote><div><br>Because I failed to realize all of the TemplateDeductionResult enum values were already handled. I've removed it. ;)<br><br>Thanks for the feedback!<br><br>Cheers,<br>
Kaelyn<br></div></div><br>