<div dir="ltr">Maybe you can try `CXXRecordDecl::fields()`?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 1, 2020 at 10:59 PM Adam McLaughlin via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">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).<div><br></div><div>-Adam</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 30, 2020 at 5:18 PM Robinson, Paul via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
> -----Original Message-----<br>
> From: cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.llvm.org</a>> On Behalf Of Marcel<br>
> Schaible via cfe-dev<br>
> Sent: Monday, November 30, 2020 11:49 AM<br>
> To: <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> Subject: [cfe-dev] RecursiveASTVisitor: How to traverse all FieldDecl in a<br>
> CXXRecordDecl?<br>
> <br>
> Hi,<br>
> <br>
> I have simple RecursiveASTVisitor, which should handle definition of<br>
> structs and their fields.<br>
> <br>
> <br>
> How can I traverse over all FieldDecl in a given CXXRecordDecl?<br>
> <br>
> Because of the sequence the AST is traversed, I don't know in a<br>
> VisitFieldDecl approach to which CXXRecordDecl it belongs to.<br>
<br>
I don't know anything about RecursiveASTVisitor so there might be<br>
a way to do what you want there. If you need to traverse the AST<br>
"manually" there's code in clang/lib/CodeGen/CGDebugInfo.cpp (look<br>
for CGDebugInfo::CollectRecordFields) that could be instructive.<br>
Note that a VarDecl describes a static data member, while a<br>
FieldDecl describes a normal data member.<br>
<br>
--paulr<br>
<br>
> <br>
> I hope I have stated my problem understandable..-<br>
> <br>
> <br>
> Thanks<br>
> <br>
> Marcel<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
> <a href="https://urldefense.com/v3/__https://lists.llvm.org/cgi-" rel="noreferrer" target="_blank">https://urldefense.com/v3/__https://lists.llvm.org/cgi-</a><br>
> bin/mailman/listinfo/cfe-dev__;!!JmoZiZGBv3RvKRSx!sAghJD5ak8TBfwxlN3-<br>
> clB7IHmStNEf-qYGycEskAWJCHsfocgsXmtBh2CP25GHZAA$<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>