[cfe-commits] r90306 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/TemplateName.h lib/AST/ASTContext.cpp lib/AST/TemplateName.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplate.cpp

Chris Lattner clattner at apple.com
Wed Dec 2 16:33:45 PST 2009


On Dec 2, 2009, at 4:28 PM, John McCall wrote:

>>>
>>> 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.
>

Sounds RAIIish

-Chris



More information about the cfe-commits mailing list