<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">Yes of course you can do that, you can first interrogate Decl::hasAttrs [1], and if that’s true you can get the AttrVec [2].</div><div class="">I would suggest to wrapp this in a custom matcher.</div><div class=""><br class=""></div><div class="">Hope this helps! </div><div class=""><br class=""></div><div class="">[1] <a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a1e0b6223e2547ac65ddbf4802117998b" class="">https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a1e0b6223e2547ac65ddbf4802117998b</a></div><div class="">[2] <a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a59463d45ab90b696a368b58d23eb49aa" class="">https://clang.llvm.org/doxygen/classclang_1_1Decl.html#a59463d45ab90b696a368b58d23eb49aa</a><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 5 Jul 2020, at 11:25, Yafei Liu via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">For example I have a struct:</div><div class=""><pre style="color:rgb(169,183,198);font-family:"JetBrains Mono",monospace;font-size:9.8pt;background-color:rgb(43,43,43)" class=""><span style="color:rgb(204,120,50)" class="">struct </span>[[clang::annotate(<span style="color:rgb(106,135,89)" class="">"example"</span>)]] ExampleStruct {<br class="">  <span style="color:rgb(204,120,50)" class="">int </span>i<span style="color:rgb(204,120,50)" class="">;<br class=""></span><span style="color:rgb(204,120,50)" class="">  float </span>f<span style="color:rgb(204,120,50)" class="">;<br class=""></span><span style="color:rgb(204,120,50)" class="">  double </span>d<span style="color:rgb(204,120,50)" class="">;<br class=""></span><span style="color:rgb(204,120,50)" class="">  int</span>* ip<span style="color:rgb(204,120,50)" class="">;<br class=""></span><span style="color:rgb(204,120,50)" class="">  </span>uint32_t ii<span style="color:rgb(204,120,50)" class="">;<br class=""></span>}<span style="color:rgb(204,120,50)" class="">;</span></pre>Currently I use the matcher like this:</div><div class=""><pre style="color:rgb(169,183,198);font-family:"JetBrains Mono",monospace;font-size:9.8pt;background-color:rgb(43,43,43)" class=""><span style="color:rgb(181,182,227)" class="">clang</span>::<span style="color:rgb(181,182,227)" class="">ast_matchers</span>::cxxRecordDecl<span style="color:rgb(95,140,138)" class="">(</span><span style="color:rgb(181,182,227)" class="">clang</span>::<span style="color:rgb(181,182,227)" class="">ast_matchers</span>::hasDefinition()<span style="color:rgb(204,120,50)" class="">,<br class=""></span><span style="color:rgb(204,120,50)" class="">    </span><span style="color:rgb(181,182,227)" class="">clang</span>::<span style="color:rgb(181,182,227)" class="">ast_matchers</span>::hasAttr(<span style="color:rgb(181,182,227)" class="">clang</span>::<span style="color:rgb(181,182,227)" class="">attr</span>::<span style="color:rgb(152,118,170);font-style:italic" class="">Annotate</span>)<span style="color:rgb(95,140,138)" class="">)</span>.bind(<span style="color:rgb(106,135,89)" class="">"example_struct"</span>)<span style="color:rgb(204,120,50)" class="">;</span></pre><b class=""></b><i class=""></i><u class=""></u><sub class=""></sub><sup class=""></sup><strike class=""></strike><br class=""></div><div class="">Can I go further by making the matcher check if the annotate is "example"?</div></div></div></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></div></body></html>