On 6/28/23 12:51, Patrick Palka wrote:
There's currently no cheap way to obtain the partial template
specialization (and arguments relative to it) that was selected for a
class or variable template specialization. Our only option is to
compute the result from scratch via most_specialized_partial_spec.
For class templates this isn't really an issue because we usually need
this information just once, upon instantiation. But for variable
templates we need it upon specialization and later upon instantiation.
It'd be good for this information to be readily available in general
however.
To that end, this patch adds a TI_PARTIAL_INFO field to TEMPLATE_INFO
that holds another TEMPLATE_INFO consisting of the partial template and
arguments relative to it, which most_specialized_partial_spec then
uses to transparently cache its (now TEMPLATE_INFO) result.
> Similarly, there's no easy way to go from the DECL_TEMPLATE_RESULT of a
partial TEMPLATE_DECL back to the TEMPLATE_DECL. (Our best option is to
walk the DECL_TEMPLATE_SPECIALIZATIONS list of the primary TEMPLATE_DECL.)
So this patch also uses this new field to link these entities in this
other direction.
You had talked about this possibly replacing the deferred_access_checks;
could they share the same slot by anonymous union? Your second use
would conflict, but perhaps the checks could move to the TEMPLATE_INFO
of the TEMPLATE_DECL now that we have a way to get at it?
In any case, this patch is OK.
Jason