[cfe-dev] Ownership of Stmts and Exprs, and destroying them

Sebastian Redl sebastian.redl at getdesigned.at
Mon Nov 24 12:13:50 PST 2008


Chris Lattner wrote:
>
> On Nov 22, 2008, at 3:36 PM, Sebastian Redl wrote:
>> Is this correct? Because I want to clean this up. I want to make the
>> Sema routines (and later the parser, too) not leak. So I need to know
>> exactly how this works.
>
> This would be great.  Probably the first place to start is to use 
> audit the parser for places where early exits cause parsed stmts to be 
> leaked.

OK, I've audited the parser. The result is attached. No regressions, and 
a clean valgrind run on Parse/statements.c. (Not leak-free. Just 
invalid-access-free.)

Not all places are fixed. In particular, array bounds and default 
arguments hidden inside a Declarator might be leaked in some places. 
Also, the additional guard is not pretty - ideally, ActionResult itself 
should be replaced by the smart pointer. This is more of a patch than a 
thorough solution.

Still, it's a start.

Sebastian
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: parser-leak.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20081124/69cab9f1/attachment.ksh>


More information about the cfe-dev mailing list