From e539c80b7c1a54b4df0cc53999e676ab4f14271f Mon Sep 17 00:00:00 2001
From: Nick Lewycky <nicholas@mxc.ca>
Date: Tue, 6 May 2014 06:35:27 +0000
Subject: [PATCH] Fix crash when one overload candidate is a template instead
 of a function. Patch by Kaelyn Takata.

Testcase coming out of creduce will land in a separate commit shortly.

Also, it appears that this callback is used even in a SFINAE context where the results are never displayed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208062 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Sema/SemaOverload.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 70f5dba56d8..7f9e0ecd96f 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -9260,6 +9260,7 @@ struct CompareOverloadCandidatesForDisplay {
           L->FailureKind == ovl_fail_too_few_arguments) {
         if (R->FailureKind == ovl_fail_too_many_arguments ||
             R->FailureKind == ovl_fail_too_few_arguments) {
+          if (!L->Function || !R->Function) return !R->Function;
           int LDist = std::abs((int)L->Function->getNumParams() - (int)NumArgs);
           int RDist = std::abs((int)R->Function->getNumParams() - (int)NumArgs);
           if (LDist == RDist)
-- 
GitLab