<div dir="ltr">Hi,<div><br></div><div>I am new to clang AST and try to parse a struct like below:</div><div><br></div><div><div>struct Foo {</div><div>    int a;</div><div>    double b;</div><div>};</div></div><div><br></div><div><br></div><div>the ast-dump result is like:</div><div><br></div><div><div>CXXRecordDecl 0x202c768 </home/lniu/ClangCheck/main.cpp:5:1, line:8:1> line:5:8 struct Foo definition</div><div>|-CXXRecordDecl 0x202c880 <col:1, col:8> col:8 implicit struct Foo</div><div>|-FieldDecl 0x202c920 <line:6:5, col:9> col:9 a 'int'</div><div>`-FieldDecl 0x202c978 <line:7:5, col:12> col:12 b 'double'</div></div><div><br></div><div>My question is How to traverse all children FieldDecl from parent CXXRecordDecl? </div><div><br></div><div>I follow the tutorial here <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__clang.llvm.org_docs_RAVFrontendAction.html&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=TqPuWCZLnY-IO9LafQXkcSpIk762vbbWxET56jjf77Q&s=9gYIUUh9eBetgoGJVhAy58A1YT1jXy3LmcfhmQEMiew&e=">http://clang.llvm.org/docs/RAVFrontendAction.html</a> and try to solve this inside bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) from a RecursiveASTVisitor<FindNamedClassVisitor>. I am expecting pseudo code like below but couldn't find the api.</div><div><br></div><div>bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {<br></div><div><br></div><div>for(ChildrenDecl decl : Declaration.getChildren()) {</div><div>// do sth here</div><div>}</div><div><br></div><div>}</div><div><br></div><div>I don't know whether I am on the right path. Any idea is welcome. Thank you!</div><div><br></div><div>Best,</div><div>Lu</div><div><br></div></div>