[cfe-commits] [PATCH] Fix Numeric literals leaks

Argyrios Kyrtzidis kyrtzidis at apple.com
Wed Aug 25 02:40:50 PDT 2010


Attached new patch with a slight modification; using the inline APInt constructor for the common case.

Also note that IntegerLiteral does not leak currently because the APInt is truncated to the biggest int of target (long long) before passing to IntegerLiteral, which for all current targets is <= 64 bits.
IntegerLiteral will leak only for a target which has set long long > 64 bits. 

In light of this, If you'd like to let IntegerLiteral use an APInt instead of the APNumericStorage, let me know.

-Argiris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: numeric_leak_fix.diff
Type: application/octet-stream
Size: 18974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100825/03797433/attachment.obj>
-------------- next part --------------

On Aug 25, 2010, at 2:01 AM, Argyrios Kyrtzidis wrote:

> The attached patch fixes the leaks of FloatingLiteral/IntegerLiteral.
> 
> For large floats/integers, APFloat/APInt will allocate memory from the heap to represent these numbers. 
> Unfortunately, when we use a BumpPtrAllocator to allocate IntegerLiteral/FloatingLiteral nodes the memory associated with
> the APFloat/APInt values will never get freed.
> I introduce the class 'APNumericStorage' which uses ASTContext's allocator for memory allocation and is used internally by FloatingLiteral/IntegerLiteral.
> 
> Please review.
> 
> -Argiris
> 
> <numeric_leak_fix.diff>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list