<div dir="ltr">So there is no way to look up typedef-name in HandleTagDeclDefinition. In this case maybe I can use the the name and type of fields of structs to identify the relevant structs but I am not sure about this.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 15, 2017 at 1:09 AM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 15 January 2017 at 01:49, Anil Altinay <span dir="ltr"><<a href="mailto:aaltinay@uci.edu" target="_blank">aaltinay@uci.edu</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"><div>Hello Mats,</div><div><br></div>I have a list of struct names and I need to change the order of fields of these structs. I think I can only do this in <span style="font-size:12.8px">HandleTagDeclDefinition because once a struct definition is completed, it is called and the changes I do here will be applied to rest of the codegen.</span></div></blockquote><div><br></div></span><div>Those structs have no name. There is a typedef-name, but the struct has no name.<br><br></div><div>Maybe the trick is to not use a list of struct names, but identify the relevant structures in some other way?<br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I can access the name of the struct which is defined using typedef keyword in HandleTranslationUnit (ASTContext &Ctx) but it is going to be too late to make changes here. Please let me know if I think wrong.</span></div></div></blockquote><div><br></div></span><div>It _may_ be too late. That depends on what you are actually trying to achieve and how. If you are re-ordering fields, then yes, it'll involve looking up all references to that field and changing it to the new index. Compilers do more difficult things throughout compilation.<br><br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Maybe there is a way to get the struct name in </span><span style="font-size:12.8px">HandleTagDeclDefinition even if it is defined with typedef but I couldn't find it.</span></div></div></blockquote><div><br></div></span><div>There is obviously a typedef name in the compiler, but it's not part of the ASTConsumer interface to "give" that name (as far as I can see). I don't know the answer to how you solve this.<br><br>--<br></div><div>Mats<br></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">thanks,</span></div><div><span style="font-size:12.8px">Anil</span></div></div><div class="m_8597882592896515083HOEnZb"><div class="m_8597882592896515083h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 14, 2017 at 2:33 PM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</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">Why do you need to know its name? If you edit the actual object, it should reflect everywhere it is referred to.<div><br></div><div>--</div><div>Mats</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_8597882592896515083m_6409518996933253221h5">On 13 January 2017 at 21:47, Anil Altinay 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_8597882592896515083m_6409518996933253221h5"><div dir="ltr">Actually, <span style="font-size:12.8px">HandleTagDeclDefinit<wbr>ion is called for Integer struct but I couldn't get the name of the struct which is "Integer" from TagDecl. Is there any way to do this in </span><span style="font-size:12.8px">HandleTagDeclDefinition function.</span></div><div class="m_8597882592896515083m_6409518996933253221m_4813178863999506271HOEnZb"><div class="m_8597882592896515083m_6409518996933253221m_4813178863999506271h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 13, 2017 at 12:22 AM, Anil Altinay <span dir="ltr"><<a href="mailto:aaltinay@uci.edu" target="_blank">aaltinay@uci.edu</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"><div>Hello,</div><div><br></div><div>I am writing an AST consumer to modify fields of the structs in a C program and let clang to generate code accordingly. I was modifying structs in HandleTagDeclDefinition(TagDec<wbr>l *D) but I realized that if a struct defined using typedef like below, HandleTagDeclDefinition is not called after it's definition is completed. Is there any way to solve this problem? Thank you.</div><div><br></div><div>typedef struct</div><div>{</div><div>    int a;</div><div>} Integer;</div><div><br></div><div>best,</div><div>Anil</div></div>
</blockquote></div><br></div>
</div></div><br></div></div>______________________________<wbr>_________________<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="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>
</blockquote></div><br></div>
</div></div></blockquote></span></div><br></div></div>
</blockquote></div><br></div>