[cfe-commits] r139417 - /cfe/trunk/lib/Sema/SemaOverload.cpp
Kaelyn Uhrain
rikka at google.com
Fri Sep 9 14:58:50 PDT 2011
Author: rikka
Date: Fri Sep 9 16:58:49 2011
New Revision: 139417
URL: http://llvm.org/viewvc/llvm-project?rev=139417&view=rev
Log:
Add smarter sorting of overload candidates that failed template deduction.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=139417&r1=139416&r2=139417&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Sep 9 16:58:49 2011
@@ -7288,6 +7288,34 @@
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 @@
} 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?
}
More information about the cfe-commits
mailing list