Match member initializers for themself

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.

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 ?

This is a bug with the way that the AST matchers register dynamic
matchers, from what I can tell. I think this is worth reporting a bug
over.

~Aaron

You're welcome to follow along: https://reviews.llvm.org/D24874

~Aaron

Great news,

thanks !