[cfe-dev] RecursiveASTVisitor: How to traverse all FieldDecl in a CXXRecordDecl? (original) (raw)
Yafei Liu via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 3 04:32:54 PST 2020
- Previous message: [cfe-dev] RecursiveASTVisitor: How to traverse all FieldDecl in a CXXRecordDecl?
- Next message: [cfe-dev] [RFC] Sort out and correct pragma align/pack stack effect
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Maybe you can try CXXRecordDecl::fields()
?
On Tue, Dec 1, 2020 at 10:59 PM Adam McLaughlin via cfe-dev < cfe-dev at lists.llvm.org> wrote:
Depending on the context of your program you can either try to 1) traverse the fields within VisitCXXRecordDecl() or 2) use the FieldDecl::getParent() method within VisitFieldDecl() to figure out which CXXRecordDecl the FieldDecl belongs to (if any).
-Adam On Mon, Nov 30, 2020 at 5:18 PM Robinson, Paul via cfe-dev <_ _cfe-dev at lists.llvm.org> wrote:
> -----Original Message----- > From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Marcel > Schaible via cfe-dev > Sent: Monday, November 30, 2020 11:49 AM > To: cfe-dev at lists.llvm.org > Subject: [cfe-dev] RecursiveASTVisitor: How to traverse all FieldDecl in a > CXXRecordDecl? > > Hi, > > I have simple RecursiveASTVisitor, which should handle definition of > structs and their fields. > > > How can I traverse over all FieldDecl in a given CXXRecordDecl? > > Because of the sequence the AST is traversed, I don't know in a > VisitFieldDecl approach to which CXXRecordDecl it belongs to. I don't know anything about RecursiveASTVisitor so there might be a way to do what you want there. If you need to traverse the AST "manually" there's code in clang/lib/CodeGen/CGDebugInfo.cpp (look for CGDebugInfo::CollectRecordFields) that could be instructive. Note that a VarDecl describes a static data member, while a FieldDecl describes a normal data member. --paulr > > I hope I have stated my problem understandable..- > > > Thanks > > Marcel > ________________________ > cfe-dev mailing list > cfe-dev at lists.llvm.org > https://urldefense.com/v3/_https://lists.llvm.org/cgi- > bin/mailman/listinfo/cfe-dev;!!JmoZiZGBv3RvKRSx!sAghJD5ak8TBfwxlN3- > clB7IHmStNEf-qYGycEskAWJCHsfocgsXmtBh2CP25GHZAA$
cfe-dev mailing list cfe-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
cfe-dev mailing list cfe-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201203/a95db02d/attachment.html>
- Previous message: [cfe-dev] RecursiveASTVisitor: How to traverse all FieldDecl in a CXXRecordDecl?
- Next message: [cfe-dev] [RFC] Sort out and correct pragma align/pack stack effect
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]