diff options
author | Kaelyn Uhrain <rikka@google.com> | 2011-09-09 21:58:49 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2011-09-09 21:58:49 +0000 |
commit | fd641f943a7d5508858fb5f449a0f5767fa34ac7 (patch) | |
tree | 05788999a710394004ee7079e6553ce629897117 | |
parent | acae01124151392a842bd6c37bd01b1ad56d6b4d (diff) |
Add smarter sorting of overload candidates that failed template deduction.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139417 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 1c78b3d113..a38b7dbd76 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -7288,6 +7288,34 @@ SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand) { return SourceLocation(); } +static unsigned RankDeductionFailure( + const OverloadCandidate::DeductionFailureInfo &DFI) { + switch (DFI.Result) { + case Sema::TDK_Success: + case Sema::TDK_Incomplete: + return 1; + + case Sema::TDK_Underqualified: + case Sema::TDK_Inconsistent: + return 2; + + case Sema::TDK_SubstitutionFailure: + case Sema::TDK_NonDeducedMismatch: + return 3; + + case Sema::TDK_InstantiationDepth: + case Sema::TDK_FailedOverloadResolution: + return 4; + + case Sema::TDK_InvalidExplicitArguments: + return 5; + + case Sema::TDK_TooManyArguments: + case Sema::TDK_TooFewArguments: + return 6; + } +} + struct CompareOverloadCandidatesForDisplay { Sema &S; CompareOverloadCandidatesForDisplay(Sema &S) : S(S) {} @@ -7368,6 +7396,15 @@ struct CompareOverloadCandidatesForDisplay { } else if (R->FailureKind == ovl_fail_bad_conversion) return false; + if (L->FailureKind == ovl_fail_bad_deduction) { + if (R->FailureKind != ovl_fail_bad_deduction) + return true; + + if (L->DeductionFailure.Result != R->DeductionFailure.Result) + return RankDeductionFailure(L->DeductionFailure) + <= RankDeductionFailure(R->DeductionFailure); + } + // TODO: others? } |