accessing struct's members

I'm using a RecursiveASTVisitor and implementing its VisitDecl()
method. Once I find one thats a stuct(by calling isStructureType()),
how can I iterate over its members?

Ive looked for uses of isStructureType() in the sources, expecting to
see it before getting its members and so far I haven't found any
examples.

Thanks

All structs should be RecordDecls; the iterator for the fields is field_begin()/field_end()

I'm using a RecursiveASTVisitor and implementing its VisitDecl()
method. Once I find one thats a stuct(by calling isStructureType()),
how can I iterate over its members?

RecordDecl::field_begin and RecordDecl::field_end.

Ive looked for uses of isStructureType() in the sources, expecting to
see it before getting its members and so far I haven't found any
examples.

Take a look at lib/AST/RecordLayoutBuilder.cpp.

-Eli

I'm a bit confused, these elements I'm iterating over(FieldDecls) cant
also be VarDecls? Also I'm getting much more output than I was
expecting/thought possible from my code. Anyone mind taking a look?

Thanks

bool VisitDecl(Decl *D) {
                RecordDecl *recordDecl = dyn_cast<RecordDecl>(D);
                if(recordDecl != NULL) {
                        errs() << "RecordDecl, ";
                        for(RecordDecl::field_iterator i =
recordDecl->field_begin(); i != recordDecl->field_end(); ++i) {
                                VarDecl *varDecl = dyn_cast<VarDecl>(*i);
                                if(varDecl != NULL)
                                        errs() << "VarDecl\n";
                                else
                                        errs() << "NOT VarDecl\n";
                        }
                 }

                return true;
}

Output:
RecordDecl, NOT VarDecl
NOT VarDecl
NOT VarDecl
NOT VarDecl
RecordDecl, NOT VarDecl
NOT VarDecl