HighCommander4 wrote:
> symbols representing instantiations of class templates will need to be stored
> in the shard of the file containing the point of instantiation
Note that the situation is complicated a bit by chains of template
instantiations. For example, consider the following set of files:
a.hpp:
```c++
template <typename T>
struct A : T {};
```
b.hpp:
```c++
template <typename T>
struct B : A<T> {};
```
first.cpp:
```c++
#include "b.hpp"
```
second.cpp:
```c++
#include "b.hpp"
class Concrete {};
class Foo : B<Concrete> {};
```
Which file's shard should store the symbol representing the instantiation
`A<Bar>`?
The **direct** point of instantiation of `A<Bar>` is in `b.hpp` -- but storing
the symbol in `b.hpp` doesn't avoid the issue discussed in the previous
comments: `first.cpp` is the first file that includes `b.hpp` to be processed,
the `A<Bar>` instantiation does not exist in it, so the shard for b.hpp is
written without `A<Bar>`, and will not be written again.
We actually need the symbol representing `A<Bar>` to be stored in `second.cpp`,
which contains `A<Bar>`'s **recursive** point of instantiation: the
non-template code that instantiated `B<Bar>`, which in turn triggered the
instantiation of `A<Bar>`.
https://github.com/llvm/llvm-project/pull/177273
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits