<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 22, 2016 at 9:44 AM, Himanshu via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all, <div><br></div><div>I tried both RecordDecl  as well as TypedefNameDecl to extract names of such struct declarations, but I always get an empty string. Could you please let me know how to extract the struct name? </div></div></blockquote><div><br></div><div>If you have the RecordDecl, you can use getTypedefNameForAnonDecl() to get the corresponding TypedefNameDecl, which will have the name 'tstr'. That only works in cases like the one below where the typedef provides a name for linkage purposes to the struct (in particular, only in C++ and only if the typedef is for exactly the struct type and not, say, a pointer to it).</div><div><br></div><div>If you want a more general solution, you'd need to walk the enclosing DeclContext looking for the matching typedef.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>For example: </div><div><br></div><div>typedef struct {</div><div>...</div><div>} tstr;</div><div><br></div><div>I want to extract 'tstr' name for this struct typedef. </div><div><br></div><div>Thanks! </div><div>--</div><div><div><div data-smartmail="gmail_signature"><div>Himanshu</div></div></div>
</div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>