[cfe-dev] Clang AST: find out functions with attribute(opencl_kernel_function)
Manuel Klimek
klimek at google.com
Mon Oct 22 00:21:27 PDT 2012
Would:
if (!FD->hasAttr<OpenCLKernelAttr>())
return;
work? (see
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?revision=166019&view=markup
)
Cheers,
/Manuel
On Wed, Oct 17, 2012 at 7:51 PM, GabrieleCocco <cocco at di.unipi.it> wrote:
> 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.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121022/ad3232db/attachment.html>
More information about the cfe-dev
mailing list