[C++20][Modules] Limit ModuleInternalLinkage to modules-ts.
authorIain Sandoe <iain@sandoe.co.uk>
Tue, 29 Jun 2021 07:06:26 +0000 (08:06 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Fri, 1 Apr 2022 08:10:30 +0000 (09:10 +0100)
commitc7ed65b4bcbd8c26704efc4193243831e3c13d3c
treecce7e3989218993ed8a445f860d58d6a480b3721
parent985c717cdbffd5da7cb188ba8b81f4fd662a81e0
[C++20][Modules] Limit ModuleInternalLinkage to modules-ts.

At present, we are generating wrong code for C++20 modules entities which
should have internal linkage.  This is because we are assigning
'ModuleInternalLinkage' unconditionally to such entities.  However this mode
is only applicable to the modules-ts.

This change makes the special linkage mode conditional on fmodules-ts and
adds a unit test to verify that we generate the correct linkage.

Currently, static variables and functions in module purview are emitted into
object files as external. On some platforms, lambdas are emitted as global
weak defintions (on Windows this causes a mangler crash).

Differential Revision: https://reviews.llvm.org/D122413
clang/lib/AST/Decl.cpp
clang/unittests/AST/DeclTest.cpp