Bug 70201 - Dump C++ template instantiations
Summary: Dump C++ template instantiations
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 enhancement
Target Milestone: ---
Assignee: Andrés Agustín Tiraboschi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-11 22:08 UTC by Daniel Gutson
Modified: 2016-05-06 14:46 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-03-14 00:00:00


Attachments
Patch adding new flag in order to dump information about template instantiations. (2.88 KB, patch)
2016-03-30 20:18 UTC, Andrés Agustín Tiraboschi
Details | Diff
Patch adding new flag in order to dump information about template instantiations. (5.52 KB, patch)
2016-05-06 14:46 UTC, Andrés Agustín Tiraboschi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Gutson 2016-03-11 22:08:54 UTC
Add a -fdump-template-instantiations option in order to dump the C++ template instantiations.

Please assign this to andres.tiraboschi@tallertechnologies.com .
Comment 1 Jonathan Wakely 2016-03-14 10:43:33 UTC
What do you plan to implement?  It would be better to produce output compatible with Templight (http://plc.inf.elte.hu/templight/) rather than a GCC-specific dump.
Comment 2 Daniel Gutson 2016-03-14 12:06:51 UTC
(In reply to Jonathan Wakely from comment #1)
> What do you plan to implement?  It would be better to produce output
> compatible with Templight (http://plc.inf.elte.hu/templight/) rather than a
> GCC-specific dump.

Actually I planned to implement the human-friendly format that gcc currently outputs when an instantiation fails [with T=...], which I think it will be useful for most users; however I admit that hving templight support is interesting.
So I propose to implement
   -fdump-template-instantations=human
or alike, leaving the code cleanly ready to add other dump formats (such as =templight) or =plugin to enable user-defined dump formats (so templight could be implemented as one).
What do you think?
Comment 3 Jonathan Wakely 2016-03-14 12:23:45 UTC
As long as it doesn't make Templight output any more difficult I have no objections :-)

I don't know if Jason already started looking at what would be needed for Templight output, but he might have some suggestions.
Comment 4 Andrés Agustín Tiraboschi 2016-03-30 20:18:46 UTC
Created attachment 38139 [details]
Patch adding new flag in order to dump information about template instantiations.

Hi,
the attached patch adds a new compilation flag 'ftemplate-instantiations' in order
to allow dumping debug information for template instantiations.
This flag has 2 possible values: none(by default) and hreadable, that prints wich
templates instantiations had been made in a human readable way.
This patch was also made in order to add options easily and to interarct with
plugins.
  For example in a plugin can be defined a derived class for template_instantiations_callbacks
implementing _function_instantiation, _class_instantiation, _using_instantiation
and then using add_template_instantiations_callbacks in order to access information
about wich template instantiations had been made.

This is an updated version.

Changelog
2016-03-29  Andres Tiraboschi  <andres.tiraboschi@tallertechnologies.com>

	* gcc/c-family/c.opt (ftemplate-instantiations): New flag.
	* gcc/flag-types.h (ti_dump_options): New type.
	* gcc/cp/decl2.c (cp_write_global_declarations): Added code to dump information.
	* gcc/cp/cp-tree.h (template_instantiations_callbacks): New type.
	(call_template_instantiation_callbacks): Declare.
	(add_template_instantiations_callbacks): Likewise.
	(clean_up_callbacks): Likewise.
	* gcc/cp/pt.c (human_readable_template_instantiations): New type.
	(instantiation_callbacks): Declare.
	(call_template_instantiation_callback): New function.
	(call_template_instantiation_callbacks): Likewise.
	(add_template_instantiations_callbacks): Likewise.
	(initialize_instantiations_callbacks): Likewise.
	(clean_up_callbacks): Likewise.
	(init_template_processing): Added code to initialize instatiation_callbacks.
	(register_specialization): Added code to dump information.
    * gcc/doc/invoke.texi (ftemplate-instantiations): Added documentation.




Thanks.
Comment 5 Andrés Agustín Tiraboschi 2016-04-08 21:17:27 UTC
I'm going to upload a new version for dumping dependencies quickly, so please ignore the current attachment.
Comment 6 Andrés Agustín Tiraboschi 2016-05-06 14:46:22 UTC
Created attachment 38428 [details]
Patch adding new flag in order to dump information about template instantiations.



Changelog
2016-05-6  Andres Tiraboschi  <andres.tiraboschi@tallertechnologies.com>

	* gcc/c-family/c.opt (ftemplate-instantiations): New flag.
	* gcc/flag-types.h (ti_dump_options): New type.
	* gcc/cp/decl2.c (cp_write_global_declarations): Added code to dump information.
    * gcc/cp/pt.h: New file.
	* gcc/cp/pt.h (template_instantiations_callbacks): New type.
    (dependence_tree): Likewise.
	(call_template_instantiation_callbacks): Declare.
	(add_template_instantiations_callbacks): Likewise.
	(clean_up_callbacks): Likewise.
	* gcc/cp/pt.c (human_readable_template_instantiations): New type.
	(instantiation_callbacks): Declare.
	(call_template_instantiation_callback): New function.
	(add_template_instantiations_callbacks): Likewise.
	(initialize_instantiations_callbacks): Likewise.
	(clean_up_callbacks): Likewise.
	(init_template_processing): Added code to initialize instatiation_callbacks.
	(register_specialization): Added code to dump information.
    (retrieve_specialization): Likewise.
    (lookup_template_class): Likewise.
    (lookup_template_function): Likewise.
    * gcc/doc/invoke.texi (ftemplate-instantiations): Added documentation.
    * gcc/cp/config-lang.in (gtfiles): Added \$(srcdir)/cp/pt.h
    * gcc/cp/Make-lang.in (CP_PLUGIN_HEADERS): Added pt.h.
    * gcc/cp/cp-lang.c: pt.h included.