Skip to content

Commit 29b9f9d

Browse files
add IsCUDAFunction
1 parent 2df83a9 commit 29b9f9d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/CppInterOp/CppInterOp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ CPPINTEROP_API bool IsNamespace(TCppScope_t scope);
281281
/// Checks if the scope is a class or not.
282282
CPPINTEROP_API bool IsClass(TCppScope_t scope);
283283

284+
/// Checks if the scope is a CUDA function or not.
285+
CPPINTEROP_API bool IsCUDAFunction(TCppScope_t scope);
286+
284287
/// Checks if the scope is a function.
285288
CPPINTEROP_API bool IsFunction(TCppScope_t scope);
286289

lib/CppInterOp/CppInterOp.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,17 @@ bool IsNamespace(TCppScope_t scope) {
304304
return isa<NamespaceDecl>(D);
305305
}
306306

307+
bool IsCUDAFunction(TCppScope_t scope) {
308+
Decl* D = static_cast<Decl*>(scope);
309+
if (auto *FD = llvm::dyn_cast<FunctionDecl>(D)) {
310+
for (const auto &i: FD->attrs()) {
311+
if (i->getKind() == clang::attr::Kind::CUDAGlobal)
312+
return true;
313+
}
314+
}
315+
return false;
316+
}
317+
307318
bool IsClass(TCppScope_t scope) {
308319
Decl* D = static_cast<Decl*>(scope);
309320
return isa<CXXRecordDecl>(D);

0 commit comments

Comments
 (0)