Declaration for TemplateTypeParmType

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Declaration for TemplateTypeParmType

Abramo Bagnara-2

We have not found any way to get declaration from TemplateTypeParmType
(while this is feasibile for UnresolvedUsingType, TypedefType,
RecordType, EnumType, InjectedClassNameType).

What is the proper way to associate TemplateTypeParmType to its
TemplateTypeParmDecl?
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Declaration for TemplateTypeParmType

John McCall
On Jun 13, 2010, at 12:16 AM, Abramo Bagnara wrote:
> We have not found any way to get declaration from TemplateTypeParmType
> (while this is feasibile for UnresolvedUsingType, TypedefType,
> RecordType, EnumType, InjectedClassNameType).
>
> What is the proper way to associate TemplateTypeParmType to its
> TemplateTypeParmDecl?

By finding the template parameters from the appropriate enclosing context.
That's... not really a satisfying answer.

Doug, is there a good reason the optional IdentifierInfo isn't an optional
TemplateTypeParmDecl?  Just to save a very small amount of memory
when there are lots of out-of-line template member declarations?

John.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Declaration for TemplateTypeParmType

Douglas Gregor

On Jun 13, 2010, at 1:22 AM, John McCall wrote:

> On Jun 13, 2010, at 12:16 AM, Abramo Bagnara wrote:
>> We have not found any way to get declaration from TemplateTypeParmType
>> (while this is feasibile for UnresolvedUsingType, TypedefType,
>> RecordType, EnumType, InjectedClassNameType).
>>
>> What is the proper way to associate TemplateTypeParmType to its
>> TemplateTypeParmDecl?
>
> By finding the template parameters from the appropriate enclosing context.
> That's... not really a satisfying answer.
>
> Doug, is there a good reason the optional IdentifierInfo isn't an optional
> TemplateTypeParmDecl?  Just to save a very small amount of memory
> when there are lots of out-of-line template member declarations?


The intent is to reduce memory usage, since I'd imagined that there were many depth-0, index-0 template parameters named 'T' or '_Tp' in any given translation unit. Frankly, I doubt that it's that big a deal, and storing a TemplateTypeParmDecl* would be more consistent with the rest of the type system.

I see that we could actually make TemplateTypeParmType itself smaller, by storing a single uintptr_t that is either (1) a TemplateTypeParmDecl*, or (2) a bit-field containing Depth/Index/ParameterPack.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Declaration for TemplateTypeParmType

Abramo Bagnara-2
Il 14/06/2010 18:21, Douglas Gregor ha scritto:

>
> On Jun 13, 2010, at 1:22 AM, John McCall wrote:
>
>> On Jun 13, 2010, at 12:16 AM, Abramo Bagnara wrote:
>>> We have not found any way to get declaration from TemplateTypeParmType
>>> (while this is feasibile for UnresolvedUsingType, TypedefType,
>>> RecordType, EnumType, InjectedClassNameType).
>>>
>>> What is the proper way to associate TemplateTypeParmType to its
>>> TemplateTypeParmDecl?
>>
>> By finding the template parameters from the appropriate enclosing context.
>> That's... not really a satisfying answer.
>>
>> Doug, is there a good reason the optional IdentifierInfo isn't an optional
>> TemplateTypeParmDecl?  Just to save a very small amount of memory
>> when there are lots of out-of-line template member declarations?
>
>
> The intent is to reduce memory usage, since I'd imagined that there were many depth-0, index-0 template parameters named 'T' or '_Tp' in any given translation unit. Frankly, I doubt that it's that big a deal, and storing a TemplateTypeParmDecl* would be more consistent with the rest of the type system.
>
> I see that we could actually make TemplateTypeParmType itself smaller, by storing a single uintptr_t that is either (1) a TemplateTypeParmDecl*, or (2) a bit-field containing Depth/Index/ParameterPack.
I've attached the patch for your review/approval.

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

TTPT_getDecl.patch (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Declaration for TemplateTypeParmType

Douglas Gregor
Hello Abramo,

On Jun 16, 2010, at 7:39 AM, Abramo Bagnara wrote:

> Il 14/06/2010 18:21, Douglas Gregor ha scritto:
>>
>> On Jun 13, 2010, at 1:22 AM, John McCall wrote:
>>
>>> On Jun 13, 2010, at 12:16 AM, Abramo Bagnara wrote:
>>>> We have not found any way to get declaration from TemplateTypeParmType
>>>> (while this is feasibile for UnresolvedUsingType, TypedefType,
>>>> RecordType, EnumType, InjectedClassNameType).
>>>>
>>>> What is the proper way to associate TemplateTypeParmType to its
>>>> TemplateTypeParmDecl?
>>>
>>> By finding the template parameters from the appropriate enclosing context.
>>> That's... not really a satisfying answer.
>>>
>>> Doug, is there a good reason the optional IdentifierInfo isn't an optional
>>> TemplateTypeParmDecl?  Just to save a very small amount of memory
>>> when there are lots of out-of-line template member declarations?
>>
>>
>> The intent is to reduce memory usage, since I'd imagined that there were many depth-0, index-0 template parameters named 'T' or '_Tp' in any given translation unit. Frankly, I doubt that it's that big a deal, and storing a TemplateTypeParmDecl* would be more consistent with the rest of the type system.
>>
>> I see that we could actually make TemplateTypeParmType itself smaller, by storing a single uintptr_t that is either (1) a TemplateTypeParmDecl*, or (2) a bit-field containing Depth/Index/ParameterPack.
>
> I've attached the patch for your review/approval.
> <TTPT_getDecl.patch>

Looks good, thanks!

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev