Would:<br><br>  if (!FD->hasAttr<OpenCLKernelAttr>())<br>    return;<br><br>work? (see <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?revision=166019&view=markup">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?revision=166019&view=markup</a>)<br>
<br>Cheers,<br>/Manuel<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 17, 2012 at 7:51 PM, GabrieleCocco <span dir="ltr"><<a href="mailto:cocco@di.unipi.it" target="_blank">cocco@di.unipi.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi.<br>
I'm currently developing a standalone tool using Clang to find (and do some<br>
transformation) functions declared using the OpenCL kernel syntax, i.e.<br>
<br>
kernel void fun(...) { }<br>
<br>
While traversing the AST and dumping functions, I discovered "kernel" means<br>
__attribute__(opencl_kernel_syntax).<br>
Anyway, I'm not sure about how to determine is a functions has this<br>
attribute.<br>
By now, the code looks like:<br>
<br>
FunctionDecl* function = static_cast<FunctionDecl*>(declaration);<br>
if(function->hasAttrs()) {<br>
  AttrVec attributes = function->getAttrs();<br>
  for(Decl::attr_iterator iterator = function->attr_begin(); iterator !=<br>
function->attr_end(); iterator++) {<br>
       Attr* attribute = *iterator;<br>
  }<br>
}<br>
<br>
Anyway, I'm not able to figure out how to use the class Attr to determine<br>
that the attribute considered is just opencl_kernel_syntax.<br>
Can you help me?<br>
<br>
Thank you very much!<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/Clang-AST-find-out-functions-with-attribute-opencl-kernel-function-tp4027510.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Clang-AST-find-out-functions-with-attribute-opencl-kernel-function-tp4027510.html</a><br>

Sent from the Clang Developers mailing list archive at Nabble.com.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>