static void EraseUnwantedCUDAMatchesImpl(Sema &S, const FunctionDecl *Caller, llvm::SmallVectorImpl<T> &Matches, FetchDeclFn FetchDecl) { assert(S.getLangOpts().CUDATargetOverloads && "Should not be called w/o enabled target overloads."); if (Matches.size() <= 1) return; // Find the best call preference among the functions in Matches. Sema::CUDAFunctionPreference P, BestCFP = Sema::CFP_Never; for (auto const &Match : Matches) { P = S.IdentifyCUDAPreference(Caller, FetchDecl(Match)); if (P > BestCFP) BestCFP = P; } // Erase all functions with lower priority. for (unsigned I = 0, N = Matches.size(); I != N;) if (S.IdentifyCUDAPreference(Caller, FetchDecl(Matches[I])) < BestCFP) { Matches[I] = Matches[--N]; Matches.resize(N); } else { ++I; } }