<div dir="ltr">Yeah it confuses me a lot to see that almost all cuda attributes, such as "__host__", "__global__", "__constant__", "__device_builtin_surface_type__" and "__device_builtin_texture_type__", are retained by the AST, but just not "__device_builtin__".<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 30, 2020 at 8:14 AM David Rector <<a href="mailto:davrecthreads@gmail.com">davrecthreads@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
> On Jul 29, 2020, at 10:07 AM, Aaron Ballman via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
> <br>
> On Wed, Jul 29, 2020 at 8:47 AM Oliver Zhang via cfe-dev<br>
> <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
>> <br>
>> Hi,<br>
>> <br>
>> 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__.)<br>
>> <br>
>> Can anyone please provide any information on how to customize the matcher to match the ignored attribute?<br>
> <br>
> I suspect you cannot match against the ignored attribute because<br>
> ignored attributes are not typically retained by the AST:<br>
> <a href="https://godbolt.org/z/4v574o" rel="noreferrer" target="_blank">https://godbolt.org/z/4v574o</a><br>
<br>
FWIW, I think it should be retained.  If we are already retaining loads of type sugar nodes, which like ignored attributes have no effect on semantics, why not just make it a policy to keep a representation of all written syntax in the AST?<br>
<br>
In fact, I would even go so far as to say macro expansions should be represented in the AST, or at least any with balanced delimiters — we could have Decl & Stmt & Expr "sugar" nodes akin to what a TypedefType is for Types.  But I grant that would be a bigger step.<br>
<br>
> <br>
> Or are you finding that the AST has the attribute but it's not<br>
> matching (perhaps because of handling  __device_builtin__ vs<br>
> device_builtin differently in the AST matchers)?<br>
> <br>
> ~Aaron<br>
> <br>
>> <br>
>> Thanks,<br>
>> Oliver<br>
>> _______________________________________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote></div>