[PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 4 16:53:40 PDT 2015


rsmith accepted this revision.

================
Comment at: lib/AST/ItaniumMangle.cpp:504
@@ +503,3 @@
+  if (FD->hasAttr<CUDADeviceAttr>() && FD->hasAttr<CUDAHostAttr>())
+    Out << "Ua6deviceUa4host";
+
----------------
If we have `enable_if` on a `__host__` `__device__` function, I think we should mangle as `Ua6deviceUa9enable_ifI...EUa4host`. (The relative order of `enable_if` attributes matters, but the order of them relative to `host` and `device` does not, so retaining alphabetical order seems best.)

================
Comment at: lib/Sema/SemaCUDA.cpp:216
@@ +215,3 @@
+    Sema &S, const FunctionDecl *Caller, llvm::SmallVectorImpl<T> &Matches,
+    std::function<const FunctionDecl *(const T)> FetchDecl) {
+  assert(S.getLangOpts().CUDATargetOverloads &&
----------------
We don't need the overhead of `std::function` here. Use this instead:

  template<typename T, typename FetchDeclFn>
  static void Erase...(
    ...,
    FetchDeclFn FetchDecl) {


http://reviews.llvm.org/D12453





More information about the cfe-commits mailing list