[C++20] [Modules] Emit full specialization of variable template as available external...
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Tue, 3 Jan 2023 06:37:56 +0000 (14:37 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Tue, 3 Jan 2023 06:48:29 +0000 (14:48 +0800)
commit367e618fd605353ad77bb78f884c758948f0d573
tree2bbdd75bfec1019f6444bbb70cfe9616beffcb4c
parent6a0333a170f55226e1d11f8b2e90a96535eac33d
[C++20] [Modules] Emit full specialization of variable template as available externally in importers

Closes https://github.com/llvm/llvm-project/issues/59780.

In this issue report, when we use full specialization of variable
templates in modules, we will meet the multiple definition errors.

The root cause of the problem is that when we see the full
specialization of the variable template in the importers, we will find
if it is already defined in the external sources and we failed to find
such definitions from external sources. So we generate the definition in
the current TU. We failed to find the definition in the external sources
because we restricted to not write it during writing. However, we don't
know why we restricted it and it doesn't make a lot sense to do such
restriction. Then no test fails after we remove such limitations. So
let's remove it now and add it back later if we found it is necessary
then we can add the corresponding test that time.

Note that the code is only applied to named modules and
PCHWithObjectFiles. So it won't affect the normal clang modules and
header units.
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/Modules/pr59780.cppm [new file with mode: 0644]