From 6fe5cccc39874f284f31574b5c1c12c5c88d9206 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Tue, 4 Nov 2025 15:49:58 +0100 Subject: [PATCH] add `IsCUDAFunction` --- include/CppInterOp/CppInterOp.h | 3 +++ lib/CppInterOp/CppInterOp.cpp | 11 +++++++++++ 2 files changed, 14 insertions(+) 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);