<div dir="ltr"><div><div>Hello,<br><br>How can I find by AST visitor for which fields destructors are called?<br><br>for the following code:<br>  struct WithDestr {<br>    int *i;<br><br>    WithDestr() : i(nullptr) { }<br><br>    virtual ~WithDestr() { delete i; }<br>  };<br><br>  struct Other {<br>    WithDestr d;<br>    long *ptr;<br>    Other() { }<br>    virtual ~Other() { delete ptr; }<br>  };<br><br></div>In AST I see only the construction of field d, but do not see anywhere destruction of d.<br><br>|-CXXRecordDecl 0x9130050 <line:13:3, line:18:3> line:13:10 struct Other definition<br>| |-CXXRecordDecl 0x9130100 <col:3, col:10> col:10 implicit referenced struct Other<br>| |-FieldDecl 0x9130160 <line:14:5, col:15> col:15 d 'struct WithDestr'<br>| |-FieldDecl 0x91301c0 <line:15:5, col:11> col:11 referenced ptr 'long * '<br>| |-CXXConstructorDecl 0x9130240 <line:16:5, col:15> col:5 Other 'void (void) __attribute__((cdecl))'<br>| | |-CXXCtorInitializer Field 0x9130160 'd' 'struct WithDestr'<br>| | | `-CXXConstructExpr 0x9176ae8 <col:5> 'struct WithDestr' 'void (void) __attribute__((cdecl))'<br>| | `-CompoundStmt 0x9176b30 <col:13, col:15><br>| |-CXXDestructorDecl 0x9176850 <line:17:5, col:36> col:13 used ~Other 'void (void) __attribute__((cdecl)) noexcept' virtual<br>| | `-CompoundStmt 0x9176b98 <col:22, col:36><br>| |   `-CXXDeleteExpr 0x9176b80 <col:24, col:31> 'void'<br>| |     `-ImplicitCastExpr 0x9176b70 <col:31> 'long * ' <LValueToRValue><br>| |       `-MemberExpr 0x9176b50 <col:31> 'long * ' lvalue ->ptr 0x91301c0<br>| |         `-CXXThisExpr 0x9176b40 <col:31> 'struct Other * ' this<br><br><br><br></div>Thanks!<br><div>Vladimir.<br></div></div>