AST-dump

I think I have found the solution. This is the matcher:

DeclarationMatcher DefaultMatcher =
constructorDecl(
isDefinition(), parameterCountIs(0),
anyOf(
hasAnyConstructorInitializer(isWritten()), has(compoundStmt(has(stmt())))
),
ofClass(
recordDecl(
unless(
hasMethod(
constructorDecl(
allOf(
hasAnyParameter(anything()), unless(isImplicit())
)
)
)
)
)
)
).bind(“default_matcher”);

I look for the constructor definition and then ask if the class it belongs to a class with the constraints I need. It is simply a swap in the approach. How do you see it? I’ve been testing it and it works, but I would like you to verify it as I might be forgetting something with all this mess :slight_smile:

Well, you first have to get to the actual definition. Since it’s not in the class, you could take the declaration you found and look for redeclarations that are definitions - one could build a matcher for that that would work like hasRedeclaration(…).

Of course, this would be great as well.

Thanks,

Pedro.

El dia 10 jun 2013 13:38, Manuel Klimek klimek@google.com escribió:

I think I have found the solution. This is the matcher:

DeclarationMatcher DefaultMatcher =
    constructorDecl(
            isDefinition(), parameterCountIs(0),
             anyOf(
                hasAnyConstructorInitializer(isWritten()),
has(compoundStmt(has(stmt())))
            ),
            ofClass(
                recordDecl(
                    unless(
                        hasMethod(
                            constructorDecl(
                                allOf(
                                    hasAnyParameter(anything()),
unless(isImplicit())
                                )
                            )
                        )
                    )
                )
            )
    ).bind("default_matcher");

I look for the constructor definition and then ask if the class it belongs
to a class with the constraints I need. It is simply a swap in the
approach. How do you see it? I've been testing it and it works, but I would
like you to verify it as I might be forgetting something with all this mess
:slight_smile:

Yes, that should work, too.