Using this as my input file<br><br>struct AA {<br>    int a, b, c;<br>};<br>void funcAZ() {}<br>int main(){<br>    struct AA aa;<br>    int a=1;<br>}<br><br>I am able to print out the functions and the int field a, b, c. However i decided to use TraverseFieldDecl and i stepped through it to see what it did. I'm confused by it<br>
<br>How do i use TraverseFieldDecl to call a function which i can run the code marked with /*thisline*/ ?<br><br>class PrintFunctionsConsumer : public ASTConsumer, public RecursiveASTVisitor<PrintFunctionsConsumer> {<br>
    public:<br>    virtual void HandleTopLevelDecl(DeclGroupRef DG) {<br>        for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {<br>            Decl *D = *i;<br>            if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)){<br>
                llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";<br>            }<br>            //this->TraverseFieldDecl(D);<br>            if (auto *ND = dyn_cast_or_null<RecordDecl>(D)){<br>
/*!!!!!!!!*/     this->TraverseRecordDecl(ND);<br>                for(auto c = ND->decls_begin(); c!=ND->decls_end(); ++c){<br>                    auto v = *c;<br>/*thisline*/     v=v;<br>                    if(const FieldDecl*f = dyn_cast<FieldDecl>(v)){<br>
                        //v->getName<br>                        llvm::errs() << "field: " << f->getName() << "\n";<br>                    }<br>                }<br>            }<br>
        }<br>    }<br>};<br><div></div>