[cfe-dev] "__device_builtin__" attribute ignored by clang AST matcher

Oliver Zhang via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 29 19:48:22 PDT 2020


I believe __device_builtin__ isn't even retained by the AST:
https://godbolt.org/z/r7Kahd. I also verified its absence using
clang::Decl::attrs().

It's interesting to see that the AST (at least in clang-11) retains both
"__device_builtin_surface_type__" and "__device_builtin_texture_type__" but
just not "__device_builtin__" in clang/Sema/AttrParsedAttrKinds.inc.

-Oliver

On Wed, Jul 29, 2020 at 10:08 PM Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Wed, Jul 29, 2020 at 8:47 AM Oliver Zhang via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
> >
> > Hi,
> >
> > I'd like to use the clang AST matcher to match the "__device_builtin__"
> attribute (ie, "__attribute__((device_builtin))") in pre-processed cuda
> code, but it seems that the matcher just ignores the attribute. (In
> clang/Sema/AttrParsedAttrKinds.inc, "AttributeCommonInfo::IgnoredAttribute"
> is returned upon __device_builtin__.)
> >
> > Can anyone please provide any information on how to customize the
> matcher to match the ignored attribute?
>
> I suspect you cannot match against the ignored attribute because
> ignored attributes are not typically retained by the AST:
> https://godbolt.org/z/4v574o
>
> Or are you finding that the AST has the attribute but it's not
> matching (perhaps because of handling  __device_builtin__ vs
> device_builtin differently in the AST matchers)?
>
> ~Aaron
>
> >
> > Thanks,
> > Oliver
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200730/71b5c8ff/attachment.html>


More information about the cfe-dev mailing list