Revert "[CUDA][HIP] Fix typo in `BestViableFunction`"

Broke the msan buildbots (see comments on rL372318 for more details).

This reverts commit eb231d1582.

llvm-svn: 372353
This commit is contained in:
Mitch Phillips 2019-09-19 21:11:28 +00:00
parent 75fbb171c3
commit 08f938bd1a
3 changed files with 9 additions and 30 deletions

View File

@ -9422,19 +9422,17 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc,
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(S.CurContext); const FunctionDecl *Caller = dyn_cast<FunctionDecl>(S.CurContext);
bool ContainsSameSideCandidate = bool ContainsSameSideCandidate =
llvm::any_of(Candidates, [&](OverloadCandidate *Cand) { llvm::any_of(Candidates, [&](OverloadCandidate *Cand) {
// Consider viable function only. return Cand->Function &&
return Cand->Viable && Cand->Function &&
S.IdentifyCUDAPreference(Caller, Cand->Function) == S.IdentifyCUDAPreference(Caller, Cand->Function) ==
Sema::CFP_SameSide; Sema::CFP_SameSide;
}); });
if (ContainsSameSideCandidate) { if (ContainsSameSideCandidate) {
// Clear viable flag for WrongSide varible candidates. auto IsWrongSideCandidate = [&](OverloadCandidate *Cand) {
llvm::for_each(Candidates, [&](OverloadCandidate *Cand) { return Cand->Function &&
if (Cand->Viable && Cand->Function && S.IdentifyCUDAPreference(Caller, Cand->Function) ==
S.IdentifyCUDAPreference(Caller, Cand->Function) == Sema::CFP_WrongSide;
Sema::CFP_WrongSide) };
Cand->Viable = false; llvm::erase_if(Candidates, IsWrongSideCandidate);
});
} }
} }

View File

@ -402,20 +402,3 @@ __host__ void test_host_template_overload() {
__device__ void test_device_template_overload() { __device__ void test_device_template_overload() {
template_overload(1); // OK. Attribute-based overloading picks __device__ variant. template_overload(1); // OK. Attribute-based overloading picks __device__ variant.
} }
// Two classes with `operator-` defined. One of them is device only.
struct C1;
struct C2;
__device__
int operator-(const C1 &x, const C1 &y);
int operator-(const C2 &x, const C2 &y);
template <typename T>
__host__ __device__ int constexpr_overload(const T &x, const T &y) {
return x - y;
}
// Verify that function overloading doesn't prune candidate wrongly.
int test_constexpr_overload(C2 &x, C2 &y) {
return constexpr_overload(x, y);
}

View File

@ -74,13 +74,11 @@ struct B4_with_device_copy_ctor {
struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor { struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor {
}; };
// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable: call to invalid function from __host__ function}} // expected-note@-3 {{copy constructor of 'C4_with_collision' is implicitly deleted because base class 'B4_with_device_copy_ctor' has no copy constructor}}
// expected-note@-4 {{implicit copy constructor inferred target collision: call to both __host__ and __device__ members}}
// expected-note@-5 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
void hostfoo4() { void hostfoo4() {
C4_with_collision c; C4_with_collision c;
C4_with_collision c2 = c; // expected-error {{no matching constructor for initialization of 'C4_with_collision'}} C4_with_collision c2 = c; // expected-error {{call to implicitly-deleted copy constructor of 'C4_with_collision'}}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------