diff options
author | Michael Liao <michael.hliao@gmail.com> | 2019-09-19 13:14:03 +0000 |
---|---|---|
committer | Michael Liao <michael.hliao@gmail.com> | 2019-09-19 13:14:03 +0000 |
commit | f2fcfddc47faf4ca932ace58ca0df87ca4ef0310 (patch) | |
tree | d78bc96c4e478507dd76550540315848d38a30e2 /lib/Sema/SemaOverload.cpp | |
parent | 23d1a459594f2fcf33a00b355fec6a75b349f38d (diff) | |
download | clang-f2fcfddc47faf4ca932ace58ca0df87ca4ef0310.tar.gz |
[CUDA][HIP] Fix typo in `BestViableFunction`
Summary:
- Should consider viable ones only when checking SameSide candidates.
- Replace erasing with clearing viable flag to reduce data
moving/copying.
- Add one and revise another one as the diagnostic message are more
relevant compared to previous one.
Reviewers: tra
Subscribers: cfe-commits, yaxunl
Tags: #clang
Differential Revision: https://reviews.llvm.org/D67730
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 9cf778f934..3e07bd2181 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -9422,17 +9422,19 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, const FunctionDecl *Caller = dyn_cast<FunctionDecl>(S.CurContext); bool ContainsSameSideCandidate = llvm::any_of(Candidates, [&](OverloadCandidate *Cand) { - return Cand->Function && + // Consider viable function only. + return Cand->Viable && Cand->Function && S.IdentifyCUDAPreference(Caller, Cand->Function) == Sema::CFP_SameSide; }); if (ContainsSameSideCandidate) { - auto IsWrongSideCandidate = [&](OverloadCandidate *Cand) { - return Cand->Function && - S.IdentifyCUDAPreference(Caller, Cand->Function) == - Sema::CFP_WrongSide; - }; - llvm::erase_if(Candidates, IsWrongSideCandidate); + // Clear viable flag for WrongSide varible candidates. + llvm::for_each(Candidates, [&](OverloadCandidate *Cand) { + if (Cand->Viable && Cand->Function && + S.IdentifyCUDAPreference(Caller, Cand->Function) == + Sema::CFP_WrongSide) + Cand->Viable = false; + }); } } |