[cfe-dev] Match member initializers for themself

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 23 08:01:37 PDT 2016


On Fri, Sep 23, 2016 at 9:07 AM, David Come via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> 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

>
>
> Thanks !
>
> David.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list