On Dec 2, 2009, at 4:20 PM, Chris Lattner wrote:

> On Dec 2, 2009, at 11:22 AM, John McCall wrote:
>> On Dec 2, 2009, at 10:02 AM, Chris Lattner wrote:
>>> On Dec 2, 2009, at 12:04 AM, John McCall wrote:
>>>> Author: rjmccall
>>>> Date: Wed Dec  2 02:04:21 2009
>>>> New Revision: 90306
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=90306&view=rev
>>>> Log:
>>>> Push overloaded function templates through the parser using a totally 
>>>> different
>>>> leaked data structure than before.
>>> 
>>> 'leaked'?
>> 
>> 
>> In the lesser sense that the memory belongs to the ASTContext.  The problem 
>> is that we need to tell the parser that a TemplateTy actually refers to N 
>> overloaded function templates, and like all the other opaque types, it only 
>> allows a single pointer, so we need to allocate something to store them, 
>> even if temporary (or change the parser to store these differently, but that 
>> requires fussing with the token-annotation system &c.).  As it happens, an 
>> overloaded TemplateTy is going to be either (1) quickly consumed as an 
>> expression when the template arguments are parsed or (2) discarded as 
>> ill-formed in the current location.  In principle you could exploit that to 
>> avoid leaking the overload storage, but that's hard to make actually work;  
>> either Sema would need to be told when the parser discards a TemplateTy 
>> (tough because of token annotations) or Sema would have to track it somehow 
>> (tough because you can have several in-flight at once).
> 
> Hrm, that's annoying.  If there was only one in flight at a time, it could 
> just be in sema and return a pointer to it.  Since there are multiple in 
> flight, that won't work: do these things have a LIFO ordering that would 
> allow Sema to have a stack of these?

I think so, yes.  To enforce the stack discipline, we'd need the parser to 
promise to tell Sema when it's finished with a TemplateTy (or at least a 
TemplateTy of function-template kind).  I don't know how easy that'd be.

John.


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

Reply via email to