<div dir="ltr"><div>Hi Dave,</div><div><br></div><div>Thanks for your reply. I don't think it is a cxxMemberCallExpr().<br></div><div>I think it is parsing issue because this is what happens:</div><div><br></div><div>class ColorTag()</div><div>{</div><div>public:</div><div>   ColorTag():</div><div>   ~ColorTag();<br></div><div>}<br></div><div><br></div><div>ColorTag()::ColorTag() {</div><div>  //...<br></div><div>}</div><div><br></div><div>ColorTag::~ColorTag() {}<br></div><div><br></div><div>It is interpreted as: CXXMemberCallExpr() as if ColorTag::~ColorTag() was called inside the constructor. You can see below in the AST output cxxMemberCallExpr parent is CXXConstructorDecl.<br></div><div><br></div><div>`-<span style="background-color:rgb(255,255,0)">CXXConstructorDecl</span> 0x2e76988 parent 0x2e60608 prev 0x2e61578 <line:238:1, line:434:2> line:238:11 ColorTag 'void (const ColorTag &)' <br>  |-ParmVarDecl 0x2e768f8 <col:20, col:36> col:36 used tag 'const ColorTag &'<br>  |-CXXCtorInitializer 'PliObjectTag'<br>  | `-CXXConstructExpr 0x2e76b10 <line:239:7, col:39> 'PliObjectTag' 'void (const PliTag::Type)'<br>  |   `-DeclRefExpr 0x2e76ab0 <col:20, col:28> 'PliTag::Type' EnumConstant 0x2e579e8 'COLOR_NGOBJ' 'PliTag::Type'<br>  |-CXXCtorInitializer Field 0x2e60e88 'm_style' 'ColorTag::styleType'<br>  | `-ImplicitCastExpr 0x2e76bd8 <line:240:15, col:19> 'ColorTag::styleType' <LValueToRValue><br>  |   `-MemberExpr 0x2e76b88 <col:15, col:19> 'const ColorTag::styleType' lvalue .m_style 0x2e60e88<br>  |     `-DeclRefExpr 0x2e76b68 <col:15> 'const ColorTag' lvalue ParmVar 0x2e768f8 'tag' 'const ColorTag &'<br>  |-CXXCtorInitializer Field 0x2e60ee8 'm_attribute' 'ColorTag::attributeType'<br>  | `-ImplicitCastExpr 0x2e76c88 <line:241:19, col:23> 'ColorTag::attributeType' <LValueToRValue><br>  |   `-MemberExpr 0x2e76c38 <col:19, col:23> 'const ColorTag::attributeType' lvalue .m_attribute 0x2e60ee8<br>  |     `-DeclRefExpr 0x2e76c18 <col:19> 'const ColorTag' lvalue ParmVar 0x2e768f8 'tag' 'const ColorTag &'<br>  `-CompoundStmt 0x2e76fb0 <line:242:36, line:434:2><br>    |-IfStmt 0x2e76d98 <line:243:3, line:249:1><br>    | |-OpaqueValueExpr 0x2e76d80 <<invalid sloc>> 'bool'<br>    | `-CompoundStmt 0x2e76d70 <line:243:28, line:249:1><br>    |-<span style="background-color:rgb(255,255,0)">CXXMemberCallExpr</span> 0x2e76e68 <line:251:1, col:21> 'void'<br>    | `-MemberExpr 0x2e76e20 <col:1, col:12> '<bound member function type>' ->~ColorTag 0x2e61670<br>    |   `-CXXThisExpr 0x2e76e10 <col:11> 'ColorTag *' implicit this</div><div><br></div><div>So this:</div><div></div><div><div><br></div><div>class ColorTag()</div><div>{</div><div>public:</div><div>   ColorTag():</div><div>   ~ColorTag();<br></div><div>}<br></div><div><br></div><div>ColorTag()::ColorTag() {</div><div>  //...<br></div><div>}</div><div><br></div><div>ColorTag::~ColorTag() {}<br></div></div><div><br></div><div>Is interpreted like this:</div><div><br></div><div><div><div>class ColorTag()</div><div>{</div><div>public:</div><div>   ColorTag():</div><div>   ~ColorTag();<br></div><div>}<br></div><div><br></div><div>ColorTag()::ColorTag() {</div><div>  //...</div><div><div><div><div> ColorTag::~ColorTag() {}</div><div>}<br></div></div></div></div><div><br></div><div>Regards,</div><div><br></div><div>Billy.</div><div><br></div><div></div></div></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 30, 2020 at 1:27 AM David Rector <<a href="mailto:davrecthreads@gmail.com" target="_blank">davrecthreads@gmail.com</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>I think you are not distinguishing properly between the declaration of the destructor and its usage (via a CXXMemberCallExpr) within the implementation/"body" of some other method declaration (this body should be enclosed in a "CompoundStmt"). <div><br></div><div>For example, the dump of </div><div><br></div><div>```</div><div><font face="Menlo">struct ColorTag {</font></div><div><font face="Menlo">  ~ColorTag() {}<br>  void destroy() {<br>    ColorTag::~ColorTag();<br>  }<br>};</font></div><div><font face="Menlo">```</font></div><div><br></div><div>looks like this:</div><div><br></div><div>```</div><div><font face="Menlo">TranslationUnitDecl<br>`-CXXRecordDecl <line:1:1, line:5:1> line:1:8 struct ColorTag definition<br>  ...(Definition data, implicitly-generated declarations)...</font></div><div><div style="background-color:rgb(255,255,254)"><font face="Menlo">  |-CXXDestructorDecl <line:2:5, col:18> col:5 used ~ColorTag 'void () noexcept'</font></div><font face="Menlo">  |-CXXMethodDecl <line:2:5, line:4:5> line:2:10 destroy 'void ()'<br>  | `-CompoundStmt <col:20, line:4:5><br>  |   `-CXXMemberCallExpr <line:3:9, col:29> 'void'<br>  |     `-MemberExpr <col:9, col:20> '<bound member function type>' ->~ColorTag 0x55790cbbaa40<br>  |       `-CXXThisExpr <col:19> 'ColorTag *' implicit this<br></font><div><font face="Menlo">  ...</font></div><div>```</div><div><br></div><div>Hope that helps, good luck,</div><div><br></div><div>Dave</div><div><br><blockquote type="cite"><div>On Jul 29, 2020, at 10:40 AM, Billy Araujo via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr">Hi,<div><br></div><div>On project opentoonz there is a file called:</div><div>opentoonz/toonz/sources/image/pli/tags.cp<br></div><div><br></div><div>If I run clang-check, the AST it builds seems wrong.</div><div><br></div><div>clang-check -ast-dump /home/opentoonz/toonz/sources/image/pli/tags.cpp | grep -B 1 -A 1 "~ColorTag"<br></div><div><br></div><div>    |-CXXMemberCallExpr 0x22893e8 <line:253:1, col:21> 'void'<br>    | `-MemberExpr 0x22893a0 <col:1, col:12> '<bound member function type>' ->~ColorTag 0x2274c00<br>    |   `-CXXThisExpr 0x2289390 <col:11> 'ColorTag *' implicit this<br></div><div><br></div><div>Line 253 appears as a CXXMemberCallExpr instead of a CXXDestructorDecl.</div><div><br></div><div>So the AST thinks it is calling an explicit destructor method call although it is a destructor implementation.</div><div><br></div><div>clang-check --version<br>LLVM (<a href="http://llvm.org/" target="_blank">http://llvm.org/</a>):<br>  LLVM version 10.0.0<br>  <br>  Optimized build.<br>  Default target: x86_64-pc-linux-gnu<br>  Host CPU: nehalem<br></div><div><br></div><div>Is this a bug or am I missing something?</div><div><br></div><div>Regards,</div><div><br></div><div>Billy.</div><div><br></div></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" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br></div></blockquote></div><br></div></div></blockquote></div>