[cfe-dev] destroy local objects at the end of a compound statement

peter jacobsen jacobsen.peter at gmail.com
Mon Dec 10 00:42:39 PST 2012


Hi Jordan,

Thanks for this. After more thought, I realised that it was not going to be
so simple.

Peter


On Fri, Dec 7, 2012 at 7:20 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> Information like this is actually quite difficult; it's not handled at the
> AST level. The Clang Static Analyzer uses Clang's CFG to handle this,
> though you have to pass it extra options to get it to include destructors.
> Note, however, that the CFG currently does not handle destructors for
> temporaries, because of this:
>
> // Creates a temporary Foo whose lifetime now matches that of 'foo'.
> const Foo &foo = coin() ? Foo(1) : Foo(0);
>
> Clang's IRGen ("CodeGen") libraries have their own handling of this, which
> I haven't studied in detail yet. I'm sure I'll get there eventually once
> the analyzer starts handling temporary destructors.
>
> Jordan
>
>
> On Dec 7, 2012, at 5:31 , peter jacobsen <jacobsen.peter at gmail.com> wrote:
>
> > Hi All,
> >
> > I am new to Clang, so may be missing something obvious.
> >
> > I am implementing a static analyser and I want to know when objects are
> constructed and deleted:
> >
> > {
> >   MyClass c;
> > }
> >
> > in this case, I climb the Ast and visit a CXXConstructExpr but nothing
> to tell me about the implied destroy.  I could reverse iterate through the
> compound statement and look for declarations etc. But I was not expecting
> to have to do this.
> >
> > Thanks,
> > Peter
> > _______________________________________________
> > 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/20121210/460b5411/attachment.html>


More information about the cfe-dev mailing list