diff --git a/include/CppInterOp/CppInterOp.h b/include/CppInterOp/CppInterOp.h index 79cffad12..8b95c15a9 100644 --- a/include/CppInterOp/CppInterOp.h +++ b/include/CppInterOp/CppInterOp.h @@ -281,6 +281,9 @@ CPPINTEROP_API bool IsNamespace(TCppScope_t scope); /// Checks if the scope is a class or not. CPPINTEROP_API bool IsClass(TCppScope_t scope); +/// Checks if the scope is a CUDA function or not. +CPPINTEROP_API bool IsCUDAFunction(TCppScope_t scope); + /// Checks if the scope is a function. CPPINTEROP_API bool IsFunction(TCppScope_t scope); diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index 3a5a345f4..a2633eecc 100755 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -304,6 +304,17 @@ bool IsNamespace(TCppScope_t scope) { return isa(D); } +bool IsCUDAFunction(TCppScope_t scope) { + Decl* D = static_cast(scope); + if (auto* FD = llvm::dyn_cast(D)) { + for (const auto& i : FD->attrs()) { + if (i->getKind() == clang::attr::Kind::CUDAGlobal) + return true; + } + } + return false; +} + bool IsClass(TCppScope_t scope) { Decl* D = static_cast(scope); return isa(D);