On Sep 8, 2011, at 4:43 PM, Kaelyn Uhrain wrote:
> Given a file tmp.cpp containing:
>
> [snip example]
>
> 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:
>
> [snip example]
>
>
> 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:
>
> [snip much-improved example]
>
> 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.
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:
- 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)
- 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
+ default:
+ return UINT_MAX;
+ }
Why do we need a default here?
- Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits