> On 06/09/2011 03:48 PM, Jonathan Wakely wrote:
>
> When I'm working on complicated template code and debugging a mixture
> of bugs in my templates and ICEs in g++ caused by my buggy templates I
> sometimes wish I could see a dump of all the templates that the
> compiler is instantiating, so I can see at which point in a
> deeply-nested instantiation things don't happen the way I expected
> them to. With variadic templates in particular it's sometimes hard to
> visualize what's happening to your code.
> 
> Someone else asked for this the other day on gcc-help
> (http://gcc.gnu.org/ml/gcc-help/2011-06/msg00193.html) so I thought
> I'd take a look at implementing it. It turns out that or class
> templates all that's needed is something like:
> verbatim ("instantiating class template %qT", type)
> in instantiate_class_template_1 in gcc/cp/pt.c
> Presumably it wouldn't be much harder to do the same for function templates.
> 
> Is there something that does this already that I've missed? If I were
> to add a switch like -ftrace-template-instantiation to control this,
> is there any chance of getting it accepted?
> 
> It might be useful if the trace said something like:
> attempting to instantiate foo<bar>...
> attempting to instantiate foo<bar>::baz<int> ...
> successfully instantiated foo<bar>::baz<int>
> failed to instantiate foo<bar>
> with nesting to see which instantiations depend on others and to see
> which pass/fail, but I've already found it useful just to see a list
> of instantiations, in order to verify whether some refactoring reduces
> the number of instantiations.
> 
> Would anyone else find this useful, or should I just keep it in my own
> source tree for my own use?

+1 for this feature. I would find it very useful too!

Regards,
Nate.                                     

Reply via email to