[cfe-dev] Clang AST: find out functions with attribute(opencl_kernel_function)

GabrieleCocco cocco at di.unipi.it
Wed Oct 17 10:51:59 PDT 2012


Hi.
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
__attribute__(opencl_kernel_syntax).
Anyway, I'm not sure about how to determine is a functions has this
attribute. 
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!



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Clang-AST-find-out-functions-with-attribute-opencl-kernel-function-tp4027510.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list