I am trying to capture all structs that look like:
struct Obj1 {
int field1;
double field2;
template <typename Ar>
void serialize(Ar& ar) {
::serializer(ar, field1, field2);
}
};
I would like to match all structs with a template <typename Ar> void serialize(Ar& ar) method, and then collect the class FieldDecls to some place. I am currently using the following match (in clang-query):
cxxRecordDecl( has( functionTemplateDecl( has( templateTypeParmDecl() ), has( cxxMethodDecl( hasName("serialize"), parameterCountIs(1) ) ) ) ) )
and it seems if I do a fieldDecl inside cxxRecordDecl with bind would capture one and only one field. What if I want all field1, field2 and potentially fieldN?