[cfe-dev] OpenCL support

Peter Collingbourne peter at pcc.me.uk
Tue Jan 18 10:06:10 PST 2011


On Tue, Jan 18, 2011 at 09:45:11AM -0800, Chris Lattner wrote:
> +  if(getContext().getLangOptions().OpenCL) {
> +    // Toggle a kernel specification, if it's set for any declaration
> +    if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
> +      for (FunctionDecl::redecl_iterator RI = FD->redecls_begin(),
> +             RE = FD->redecls_end(); RI != RE; ++RI)
> +        if (RI->hasAttr<OpenCLKernelAttr>()) {       
> 
> I'm not an expert on this stuff, but it seems like there should be a better way to see if a function has an attribute.

Chris is right.  Because attributes are (normally) inherited from
previous redeclarations, we should only need to test FD's attributes.

Thanks,
-- 
Peter



More information about the cfe-dev mailing list