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

Chris Lattner clattner at apple.com
Fri Aug 27 10:43:35 PDT 2010


That is a very clever approach, looks great to me!

-Chris

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

> 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
> 
> <numeric_leak_fix.diff>
> 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
> 
> _______________________________________________
> 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