[cfe-dev] how to see in AST fields destruction

Vladimir Voskresensky vladimir.voskresensky at oracle.com
Mon Mar 16 15:30:00 PDT 2015


Richard,

Thanks for the quick reply.
May be you can point me to the code in LLVM where I can find the logic I 
need (find fields which must be implicitly created/destroyed)?
As destructors have to be called for fields, I assume there is such logic.
May be somewhere at AST-of-destructor => IR conversion layer?

Thanks!
Vladimir.

On 03/16/2015 09:46 PM, Richard Smith wrote:
> On Mon, Mar 16, 2015 at 7:31 AM, Vladimir Voskresensky 
> <voskresensky.vladimir at gmail.com 
> <mailto:voskresensky.vladimir at gmail.com>> wrote:
>
>     Hello,
>
>     How can I find by AST visitor for which fields destructors are called?
>
>     for the following code:
>       struct WithDestr {
>         int *i;
>
>         WithDestr() : i(nullptr) { }
>
>         virtual ~WithDestr() { delete i; }
>       };
>
>       struct Other {
>         WithDestr d;
>         long *ptr;
>         Other() { }
>         virtual ~Other() { delete ptr; }
>       };
>
>     In AST I see only the construction of field d, but do not see
>     anywhere destruction of d.
>
>
> We do not model the implicit member and base destruction actions 
> performed by a destructor in the AST.
>
>     |-CXXRecordDecl 0x9130050 <line:13:3, line:18:3> line:13:10 struct
>     Other definition
>     | |-CXXRecordDecl 0x9130100 <col:3, col:10> col:10 implicit
>     referenced struct Other
>     | |-FieldDecl 0x9130160 <line:14:5, col:15> col:15 d 'struct
>     WithDestr'
>     | |-FieldDecl 0x91301c0 <line:15:5, col:11> col:11 referenced ptr
>     'long * '
>     | |-CXXConstructorDecl 0x9130240 <line:16:5, col:15> col:5 Other
>     'void (void) __attribute__((cdecl))'
>     | | |-CXXCtorInitializer Field 0x9130160 'd' 'struct WithDestr'
>     | | | `-CXXConstructExpr 0x9176ae8 <col:5> 'struct WithDestr'
>     'void (void) __attribute__((cdecl))'
>     | | `-CompoundStmt 0x9176b30 <col:13, col:15>
>     | |-CXXDestructorDecl 0x9176850 <line:17:5, col:36> col:13 used
>     ~Other 'void (void) __attribute__((cdecl)) noexcept' virtual
>     | | `-CompoundStmt 0x9176b98 <col:22, col:36>
>     | |   `-CXXDeleteExpr 0x9176b80 <col:24, col:31> 'void'
>     | |     `-ImplicitCastExpr 0x9176b70 <col:31> 'long * '
>     <LValueToRValue>
>     | |       `-MemberExpr 0x9176b50 <col:31> 'long * ' lvalue ->ptr
>     0x91301c0
>     | |         `-CXXThisExpr 0x9176b40 <col:31> 'struct Other * ' this
>
>
>
>     Thanks!
>     Vladimir.
>
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150317/3bd50379/attachment.html>


More information about the cfe-dev mailing list