Clang AST: find out functions with attribute(opencl_kernel_function)

I'm currently developing a standalone tool using Clang to find (and do some
transformation) functions declared using the OpenCL kernel syntax, i.e.

kernel void fun(...) { }

While traversing the AST and dumping functions, I discovered "kernel" means
Anyway, I'm not sure about how to determine is a functions has this
By now, the code looks like:

FunctionDecl* function = static_cast<FunctionDecl*>(declaration);
if(function->hasAttrs()) {
  AttrVec attributes = function->getAttrs();
  for(Decl::attr_iterator iterator = function->attr_begin(); iterator !=
function->attr_end(); iterator++) {
       Attr* attribute = *iterator;

Anyway, I'm not able to figure out how to use the class Attr to determine
that the attribute considered is just opencl_kernel_syntax.
Can you help me?

Thank you very much!


if (!FD->hasAttr())

work? (see


Perfectly :slight_smile: Thank you thousand!