[cfe-dev] CFG initializers and destructors patch

Marcin Świderski marcin.sfider at gmail.com
Thu Sep 2 23:25:17 PDT 2010


W dniu 3 września 2010 06:39 użytkownik Ted Kremenek
<kremenek at apple.com>napisał:

> Hi Marcin,
>
> Thanks again for doing this.  I will try and take a look at this in detail
> in the next 24 hours and come back with feedback.  As I mentioned to
> Zhongxing and Jordy in a private email, we should hold off and committing
> any of these changes until LLVM branches tomorrow for the 2.8 release.
>
> I have one question/comment inline (below).
>
> On Sep 2, 2010, at 3:29 PM, Marcin Świderski <marcin.sfider at gmail.com>
> wrote:
>
> > Hi
> >
> > I'm sending a patch with implementation of C++
> > - initializers from constructor initialization list,
> > - implicit destructors for objects with automatic storage duration.
> >
> > For destructors I've taken care of:
> > - block local scopes,
> > - if/switch/for/while/do local scopes (in case there's no block),
> > - if/switch/for/while condition variables,
> > - catch exception variable,
> > - temporaries bound to const reference.
> >
> > Is there something that I've missed?
> >
> > As it have been suggested I've created hierarchy of CFGElements.
> Currently there're two unused types for implicit destructor calls in
> destructor. I've did not revert ability of CFGElement to cast/dyn_cast to
> Stmt, because it would lead to situation when cast<Stmt>(SomeCFGElement)
> would return null. I did however add method for downcasting CFGElement
> object to object of its implemntation class (returned by value, not pointer)
> with returning invalid object on invalid cast.
> >
> > I did not add CFGElement for destructors of temporary objects. After
> giving it some thought I came to a conclusion that it shouldn't be covered
> by CFG, because it clearly needs path-sensitiveness.
>
> How is this path-sensitive?  The compiler has to generate destructors calls
> at the IR level without doing any path-sensitive analysis at all (and
> actually no flow-sensitive analysis either).
>
> If we would want to model destructors of temporaries directly in CFG we
would have to generate blocks structure mirroring that generated for full
expression. That is because of expressions with control flow (&&, ||, ?:).
But what do we need this for?
- If we want to know of all destructors that can be called at the and of
full expression, we can look at CXXExprWithTemporaries in AST.
- If we want to know exactly what destructors will be called at the end of
full expression we can build stack of all temporaries seen on some specific
path.
Direct modeling this in CFG won't be easier to use by a client in any of
this cases IMO.

>
> >
> > Cheers
> > Marcin
> > <cfg-init-dtor.patch>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100903/69f4007f/attachment.html>


More information about the cfe-dev mailing list