<div dir="ltr">You'll probably need to implement a matcher for that, I don't think there exists one yet.<br></div><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 7:59 AM LUIS MIGUEL SANCHEZ GARCIA <<a href="mailto:luismiguel.sanchez@uc3m.es">luismiguel.sanchez@uc3m.es</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I'm trying to extract the compound or single statement contained into an C++11 attribute using "clang-query". </div><div><br></div><div><br></div><div>For example:</div><div><br></div>- file.cpp contains:<div><br></div><div><div>int main()</div><div>{</div><div> int a = 5;</div><div> int b = 6;</div><div><b> [[own::decl]] <i>//included in my clang version</i><br></b></div><div><b> for (int i=0;i<100;i++){</b></div><div><b><span style="white-space:pre-wrap"> </span>auto c = a + b;</b></div><div><b> }</b></div><div> auto j1 = 2*a ;</div><div> </div><div> return 0;</div><div>}</div></div><div><br></div><div>- using <font face="monospace, monospace">clang-query -extra-arg="-std=c++1y" file.cpp --</font></div><div><div><font face="monospace, monospace">clang-query>set output dump</font></div><div><font face="monospace, monospace">clang-query>match <b>/* something */</b></font></div></div><div><font face="monospace, monospace"><b><br></b></font></div><div>and obtain as result something like:<br></div><div><br></div><div><div>Match #1:</div><div><br></div><div>Binding for "root":</div><div>AttributedStmt 0x30cd8f0 </tmp/test01.cpp:8:5, line:11:5></div><div>|-OWNdeclAttr 0x30cd8e0 <line:8:7, col:12></div><div>`-ForStmt 0x30cd8a8 <line:9:5, line:11:5></div><div> |-DeclStmt 0x30cd580 <line:9:10, col:17></div></div><div> .......</div><div><br></div><div><br></div><div>I would like to use something similar to the example of hasAttr() (which it does not work) found in <a href="http://clang.llvm.org/docs/LibASTMatchersReference.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersReference.html</a><table style="font-family:'Lucida Grande','Lucida Sans Unicode',Arial,Verdana,Helvetica,sans-serif;line-height:19.5px"><tbody><tr style="vertical-align:top"><td style="padding:0.33em">Matcher<Decl>hasAttrattr::Kind AttrKind<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Matches declaration that has a given attribute.<br>Given<br> __attribute__((device)) void f() { ... }<br>decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of<br>f.</blockquote><br>Thanks!<br>Regards,<br>Luis.</td><td style="padding:0.33em"><br></td><td style="padding:0.33em"><br></td></tr></tbody></table><div><div><div><div><br></div>-- <br><div><div dir="ltr"><div><span style="font-size:small;font-family:arial">-- </span><br style="font-size:small;font-family:arial"><span style="font-size:small;font-family:arial">-- </span><br style="font-size:small;font-family:arial"><span style="font-size:small;font-family:arial">--------------------------------------------------</span><br style="font-size:small;font-family:arial"><span style="font-size:small;font-family:arial">Luis Miguel Sánchez García</span><br style="font-size:small;font-family:arial"><span style="font-size:small;font-family:arial;border-collapse:collapse">Computer Architecture and Technology Area.</span><div style="font-size:small;font-family:arial">Office 2.2.B08<br><div>Computer Science Department. UNIVERSIDAD CARLOS III DE MADRID<br>Universidad Carlos III de Madrid<br>Avda. de la Universidad, 30<br>28911 Leganés - Madrid - Spain<br>e-mail: <a href="mailto:lmsan@arcos.inf.uc3m.es" style="color:rgb(17,85,204)" target="_blank">lmsan@arcos.inf.uc3m.es</a><br> <a href="mailto:luismiguel.sanchez@uc3m.es" style="color:rgb(17,85,204)" target="_blank">luismiguel.sanchez@uc3m.es</a><br><br></div><div>Phone: (+34) 91 624 5951<br><div> <br>Linked-In: <a href="http://es.linkedin.com/in/lmsan" style="color:rgb(17,85,204)" target="_blank">http://es.linkedin.com/in/lmsan</a><br>Twitter: <a href="http://twitter.com/lmsanchezgarcia" style="color:rgb(17,85,204)" target="_blank">http://twitter.com/lmsanchezgarcia</a><br>--------------------------------------------------</div></div></div></div></div></div>
</div></div></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>