diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-10-10 06:42:31 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-10-10 06:42:31 +0000 |
commit | 189e52fcdfc3c3d04a3812cab72c968ca1911378 (patch) | |
tree | bbae468c3758adeb5625557d60fe2750e1d7609d /clang/lib/Sema/SemaCUDA.cpp | |
parent | ed84f4abd47efd2a3e1d810eacdc06963432f48f (diff) | |
download | bcm5719-llvm-189e52fcdfc3c3d04a3812cab72c968ca1911378.tar.gz bcm5719-llvm-189e52fcdfc3c3d04a3812cab72c968ca1911378.zip |
P0035R4: Semantic analysis and code generation for C++17 overaligned
allocation.
llvm-svn: 283722
Diffstat (limited to 'clang/lib/Sema/SemaCUDA.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCUDA.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index d6c0606674e..827eb02bcd6 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -158,6 +158,34 @@ Sema::IdentifyCUDAPreference(const FunctionDecl *Caller, llvm_unreachable("All cases should've been handled by now."); } +void Sema::EraseUnwantedCUDAMatches(const FunctionDecl *Caller, + LookupResult &R) { + if (R.isSingleResult()) + return; + + // Gets the CUDA function preference for a call from Caller to Match. + auto GetCFP = [&](const NamedDecl *D) { + if (auto *Callee = dyn_cast<FunctionDecl>(D->getUnderlyingDecl())) + return IdentifyCUDAPreference(Caller, Callee); + return CFP_Never; + }; + + // Find the best call preference among the functions in R. + CUDAFunctionPreference BestCFP = GetCFP(*std::max_element( + R.begin(), R.end(), [&](const NamedDecl *D1, const NamedDecl *D2) { + return GetCFP(D1) < GetCFP(D2); + })); + + // Erase all functions with lower priority. + auto Filter = R.makeFilter(); + while (Filter.hasNext()) { + auto *Callee = dyn_cast<FunctionDecl>(Filter.next()->getUnderlyingDecl()); + if (Callee && GetCFP(Callee) < BestCFP) + Filter.erase(); + } + Filter.done(); +} + template <typename T> static void EraseUnwantedCUDAMatchesImpl( Sema &S, const FunctionDecl *Caller, llvm::SmallVectorImpl<T> &Matches, |