@@ -8535,7 +8535,7 @@ void Sema::AddNonMemberOperatorCandidates(
8535
8535
if (CandidateSet.getRewriteInfo().shouldAddReversed(*this, Args, FD)) {
8536
8536
8537
8537
// As template candidates are not deduced immediately,
8538
- // persist the arry in the overload set.
8538
+ // persist the array in the overload set.
8539
8539
ArrayRef<Expr *> Reversed = CandidateSet.getPersistentArgsArray(
8540
8540
FunctionArgs[1], FunctionArgs[0]);
8541
8541
AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs,
@@ -10317,7 +10317,7 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
10317
10317
*this, Args, FTD->getTemplatedDecl())) {
10318
10318
10319
10319
// As template candidates are not deduced immediately,
10320
- // persist the arry in the overload set.
10320
+ // persist the array in the overload set.
10321
10321
if (ReversedArgs.empty())
10322
10322
ReversedArgs = CandidateSet.getPersistentArgsArray(Args[1], Args[0]);
10323
10323
@@ -11091,7 +11091,8 @@ OverloadCandidateSet::ResultForBestCandidate(const iterator &Best) {
11091
11091
return OR_Success;
11092
11092
}
11093
11093
11094
- void OverloadCandidateSet::CudaExcludeWrongSideCandidates(Sema &S) {
11094
+ void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11095
+ Sema &S, SmallVectorImpl<OverloadCandidate *> &Candidates) {
11095
11096
// [CUDA] HD->H or HD->D calls are technically not allowed by CUDA but
11096
11097
// are accepted by both clang and NVCC. However, during a particular
11097
11098
// compilation mode only one call variant is viable. We need to
@@ -11108,26 +11109,23 @@ void OverloadCandidateSet::CudaExcludeWrongSideCandidates(Sema &S) {
11108
11109
const FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true);
11109
11110
11110
11111
bool ContainsSameSideCandidate =
11111
- llvm::any_of(Candidates, [&](const OverloadCandidate & Cand) {
11112
+ llvm::any_of(Candidates, [&](const OverloadCandidate * Cand) {
11112
11113
// Check viable function only.
11113
- return Cand. Viable && Cand. Function &&
11114
- S.CUDA().IdentifyPreference(Caller, Cand. Function) ==
11114
+ return Cand-> Viable && Cand-> Function &&
11115
+ S.CUDA().IdentifyPreference(Caller, Cand-> Function) ==
11115
11116
SemaCUDA::CFP_SameSide;
11116
11117
});
11118
+
11117
11119
if (!ContainsSameSideCandidate)
11118
11120
return;
11119
11121
11120
- auto IsWrongSideCandidate = [&](const OverloadCandidate & Cand) {
11122
+ auto IsWrongSideCandidate = [&](const OverloadCandidate * Cand) {
11121
11123
// Check viable function only to avoid unnecessary data copying/moving.
11122
- return Cand. Viable && Cand. Function &&
11123
- S.CUDA().IdentifyPreference(Caller, Cand. Function) ==
11124
+ return Cand-> Viable && Cand-> Function &&
11125
+ S.CUDA().IdentifyPreference(Caller, Cand-> Function) ==
11124
11126
SemaCUDA::CFP_WrongSide;
11125
11127
};
11126
-
11127
- for (auto &Cand : Candidates) {
11128
- if (IsWrongSideCandidate(Cand))
11129
- Cand.Viable = false;
11130
- }
11128
+ llvm::erase_if(Candidates, IsWrongSideCandidate);
11131
11129
}
11132
11130
11133
11131
/// Computes the best viable function (C++ 13.3.3)
@@ -11148,9 +11146,6 @@ OverloadingResult OverloadCandidateSet::BestViableFunction(Sema &S,
11148
11146
DeferredCandidates.empty() &&
11149
11147
"Unexpected deferred template candidate");
11150
11148
11151
- if (S.getLangOpts().CUDA)
11152
- CudaExcludeWrongSideCandidates(S);
11153
-
11154
11149
bool TwoPhaseResolution = !DeferredCandidates.empty();
11155
11150
11156
11151
if (TwoPhaseResolution) {
@@ -11160,16 +11155,14 @@ OverloadingResult OverloadCandidateSet::BestViableFunction(Sema &S,
11160
11155
return ResultForBestCandidate(Best);
11161
11156
11162
11157
InjectNonDeducedTemplateCandidates(S);
11163
-
11164
- if (S.getLangOpts().CUDA)
11165
- CudaExcludeWrongSideCandidates(S);
11166
11158
}
11167
11159
11168
11160
return BestViableFunctionImpl(S, Loc, Best);
11169
11161
}
11170
11162
11171
11163
void OverloadCandidateSet::PerfectViableFunction(
11172
11164
Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best) {
11165
+
11173
11166
Best = end();
11174
11167
for (auto It = begin(); It != end(); ++It) {
11175
11168
if (It->isPerfectMatch(S.getASTContext())) {
@@ -11202,6 +11195,9 @@ OverloadingResult OverloadCandidateSet::BestViableFunctionImpl(
11202
11195
std::transform(begin(), end(), std::back_inserter(Candidates),
11203
11196
[](OverloadCandidate &Cand) { return &Cand; });
11204
11197
11198
+ if (S.getLangOpts().CUDA)
11199
+ CudaExcludeWrongSideCandidates(S, Candidates);
11200
+
11205
11201
Best = end();
11206
11202
for (auto *Cand : Candidates) {
11207
11203
Cand->Best = false;
@@ -14954,7 +14950,7 @@ void Sema::LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet,
14954
14950
AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
14955
14951
14956
14952
// As template candidates are not deduced immediately,
14957
- // persist the arry in the overload set.
14953
+ // persist the array in the overload set.
14958
14954
ArrayRef<Expr *> ReversedArgs;
14959
14955
if (CandidateSet.getRewriteInfo().allowsReversed(Op) ||
14960
14956
CandidateSet.getRewriteInfo().allowsReversed(ExtraOp))
0 commit comments