I was just reading:
… and was looking for further discussion on the handling of a class template specialization type in a case like this:
module A defines class template A, but does not use the specialization type A<int>.
B imports A and declares “void x(A<int>);"
C imports A and declares “A<int> y(int);"
D imports B, then uses x, then imports C, then uses y.
And, in D:
- before the first use of x, the program does not require the existence of the type A<int>.
- before the first use of y, the program does not require the existence of the type “function of (int) returning A<int>”.
So presumably, when B’s type block is read to simulate the forward-declaration of x at the use of x in D, the front end can use B’s types block entries as they are.
Now, when D uses y…
The section on declaration merging in PCHInternals seems to suggest that the front end cannot just use C’s type block directly when simulating y’s forward-declaration in D; instead, it has to do a deep copy of the canonical type, except that C’s info about A<int> is replaced by B’s.
Is that what actually happens, or is something else going on?
Also: are there cases where this kind of type-merging is known to be expensive?
Are there any documents that talk about alternative approaches, and are there any potentially-interesting approaches that haven’t been implemented yet?
Does the index file (“modules.idx”) play any significant role in this?