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

Attachment: numeric_leak_fix.diff
Description: Binary data

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
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to