summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorMichael Liao <michael.hliao@gmail.com>2019-09-19 21:26:18 +0000
committerMichael Liao <michael.hliao@gmail.com>2019-09-19 21:26:18 +0000
commitb8fc6a91164a29c79dc179eab82a2f41fb4b4ac4 (patch)
tree5f38cea595f444d2e1f2db1c49350e32c0d45e05 /clang/lib/Sema/SemaOverload.cpp
parent08f938bd1ae356544923042423ea3f30cd730bf8 (diff)
downloadbcm5719-llvm-b8fc6a91164a29c79dc179eab82a2f41fb4b4ac4.tar.gz
bcm5719-llvm-b8fc6a91164a29c79dc179eab82a2f41fb4b4ac4.zip
[CUDA][HIP] Re-apply part of r372318.
- r372318 causes violation of `use-of-uninitialized-value` detected by MemorySanitizer. Once `Viable` field is set to false, `FailureKind` needs setting as well as it will be checked during destruction if `Viable` is not true. - Revert the part trying to skip `std::vector` erasing. llvm-svn: 372356
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 9cf778f934c..6887cdd7ee4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9422,13 +9422,15 @@ 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 &&
+ // Check 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 &&
+ // Check viable function only to avoid unnecessary data copying/moving.
+ return Cand->Viable && Cand->Function &&
S.IdentifyCUDAPreference(Caller, Cand->Function) ==
Sema::CFP_WrongSide;
};
OpenPOWER on IntegriCloud