[clang] e264fe8 - [doc] [Modules] Document how to implement ABI compatible code in module units
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 13 01:52:19 PDT 2023
Author: Chuanqi Xu
Date: 2023-03-13T16:44:10+08:00
New Revision: e264fe89e37fc0b12e18d72ed98056cea1a9eba6
URL: https://github.com/llvm/llvm-project/commit/e264fe89e37fc0b12e18d72ed98056cea1a9eba6
DIFF: https://github.com/llvm/llvm-project/commit/e264fe89e37fc0b12e18d72ed98056cea1a9eba6.diff
LOG: [doc] [Modules] Document how to implement ABI compatible code in module units
Added:
Modified:
clang/docs/StandardCPlusPlusModules.rst
Removed:
################################################################################
diff --git a/clang/docs/StandardCPlusPlusModules.rst b/clang/docs/StandardCPlusPlusModules.rst
index bcf2c4470c521..970803b56c8c6 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -591,6 +591,19 @@ The result would be ``NS::foo at M()``, which reads as ``NS::foo()`` in module ``M`
The ABI implies that we can't declare something in a module unit and define it in a non-module unit (or vice-versa),
as this would result in linking errors.
+If we still want to implement declarations within the compatible ABI in module unit,
+we can use the language-linkage specifier. Since the declarations in the language-linkage specifier
+is attached to the global module fragments. For example:
+
+.. code-block:: c++
+
+ export module M;
+ namespace NS {
+ export extern "C++" int foo();
+ }
+
+Now the linkage name of ``NS::foo()`` will be ``_ZN2NS3fooEv``.
+
Known Problems
--------------
More information about the cfe-commits
mailing list