Using clang-query for matching C++11 attributes

Hi all,

I’m trying to extract the compound or single statement contained into an C++11 attribute using “clang-query”.

For example:

  • file.cpp contains:

int main()
int a = 5;
int b = 6;
[[own::decl]] //included in my clang version

for (int i=0;i<100;i++){
auto c = a + b;
auto j1 = 2*a ;

return 0;

  • using clang-query -extra-arg="-std=c++1y" file.cpp –

clang-query>set output dump
clang-query>match /* something */

and obtain as result something like:

Match #1:

Binding for “root”:
AttributedStmt 0x30cd8f0 </tmp/test01.cpp:8:5, line:11:5>

-OWNdeclAttr 0x30cd8e0 <line:8:7, col:12>
`-ForStmt 0x30cd8a8 <line:9:5, line:11:5>
-DeclStmt 0x30cd580 <line:9:10, col:17>

I would like to use something similar to the example of hasAttr() (which it does not work) found in

You’ll probably need to implement a matcher for that, I don’t think there exists one yet.