[cfe-dev] Match member initializers for themself

David Come via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 23 06:07:12 PDT 2016


Hi,


I'm using clang-matchers with clang-querry 3.8 and I would like to match 
members initializer for themself.


For instance,  in the following snippet

struct A
{
   int i;
   double d;
   A(){}
   A(int ii) : i(ii),d(-1.0){}
};

I would like to get i(ii) and d(-1.0).

I tried match cxxCtorInitializer(forField(hasName("i"))), which is 
exactly what I want according to the doc, but I get Not a valid 
top-level matcher.


I'm able to retrieve the constructor that holds the initializing 
expression i'm interested into with match 
cxxConstructorDecl(hasAnyConstructorInitializer(forField(hasName("i"))))

Is there something I'm doing wrong ? is there a bug in clang querry ?


Thanks !

David.




More information about the cfe-dev mailing list