Hi,
Default, copy, and move constructors are provided implicitly (under various conditions - obviously if you have members that aren’t default, copy, or move constructible, you might not/cannot get all of those)
Ok, but this keeps giving me trouble. I’ve used the isImplicit() matcher to avoid those implicit constructors, but it isn’t working how I need yet.
recordDecl(
unless(hasMethod(constructorDecl(
allOf(hasAnyParameter(anything()), unless(isImplicit()))
I know I shouldn’t use the -ast-dump-xml option, but look at this. If I have a class like this:
class E{
public:
E(){int a = 3;};
int e;
};
This is the dump of the constructor:
CompoundStmt 0xd7d81a8 <./ABC.h:4:6, col:17> `-DeclStmt 0xd7d8198 `-VarDecl 0xd7d8150 a 'int' `-IntegerLiteral 0xd7d8180 'int' 3And this case is working fine. But when the class is this other way:
class E{
public:
E();
int e;
};
E::E(){
int a = 3;
}
The dump creates two CXXConstructors, I suppose one for the declaration and the other for the definition:
…
CompoundStmt 0xc7de378 <./ABC.h:8:7, line:10:1> `-DeclStmt 0xc7de368 `-VarDecl 0xc7de320 a 'int' `-IntegerLiteral 0xc7de350 'int' 3And this is the case my matcher is not retrieving the class E. I don’t know if clang it’s considering that first CxxConstructor as implicit… The only difference I can see is the “used” attribute. I’ve tried creating a simple matcher to use the isUsed() method of Decl class:
namespace clang{
namespace ast_matchers{
AST_MATCHER(Decl, isUsed)
{
return Node.isUsed();
}
}
}
but, this is having no influence.
Maybe, I’m ignoring something.
Thanks,
Pedro.
El dia 28 may 2013 18:18, David Blaikie dblaikie@gmail.com escribió: