summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2019-01-04 15:24:06 +0000
committerErich Keane <erich.keane@intel.com>2019-01-04 15:24:06 +0000
commit414ff52d09f7a8c7156bce007357cbf579aa7c26 (patch)
tree470dc8d57f0afd54499fc827bb7432fcdf9e1682 /clang/lib/Sema/SemaOverload.cpp
parent3f4b54850f270820421400af99f9f88b346679fd (diff)
downloadbcm5719-llvm-414ff52d09f7a8c7156bce007357cbf579aa7c26.tar.gz
bcm5719-llvm-414ff52d09f7a8c7156bce007357cbf579aa7c26.zip
Prevent unreachable when checking invalid multiversion decls.
CPUSpecifc/CPUDispatch call resolution assumed that all declarations that would be passed are valid, however this was an invalid assumption. This patch deals with those situations by making the valid version take priority. Note that the checked ordering is arbitrary, since both are replaced by calls to the resolver later. Change-Id: I7ff2ec88c55a721d51bc1f39ea1a1fe242b4e45f llvm-svn: 350398
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 6f50dd9bccd..257eef435fd 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9023,6 +9023,11 @@ static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
!Cand2.Function->isMultiVersion())
return false;
+ // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, this
+ // is obviously better.
+ if (Cand1.Function->isInvalidDecl()) return false;
+ if (Cand2.Function->isInvalidDecl()) return true;
+
// If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
// cpu_dispatch, else arbitrarily based on the identifiers.
bool Cand1CPUDisp = Cand1.Function->hasAttr<CPUDispatchAttr>();
OpenPOWER on IntegriCloud