[clang] Verify internal entity module mangling
authorNathan Sidwell <nathan@acm.org>
Wed, 6 Apr 2022 14:24:06 +0000 (07:24 -0700)
committerNathan Sidwell <nathan@acm.org>
Thu, 7 Apr 2022 12:40:57 +0000 (05:40 -0700)
Internal symbol mangling is implementation-defined.  We do not mangle
any module attachment, and this adds a test to verify that.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D123220

clang/test/CodeGenCXX/cxx20-module-internal.cppm [new file with mode: 0644]

diff --git a/clang/test/CodeGenCXX/cxx20-module-internal.cppm b/clang/test/CodeGenCXX/cxx20-module-internal.cppm
new file mode 100644 (file)
index 0000000..b453583
--- /dev/null
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+// internal-linkage symbol mangling is implementation defined.  Let's
+// not mangle in the module attachment -- that unnecessarily bloats
+// the symbols.
+
+export module A;
+
+// CHECK-DAG: void @_ZL6addonev(
+static void addone() {}
+// CHECK-DAG: @_ZL1x =
+static int x = 5;
+
+namespace {
+// CHECK-DAG: void @_ZN12_GLOBAL__N_14frobEv(
+void frob() {}
+// CHECK-DAG: @_ZN12_GLOBAL__N_11yE =
+int y = 2;
+struct Bill {
+  void F();
+};
+// CHECK-DAG: void @_ZN12_GLOBAL__N_14Bill1FEv(
+void Bill::F() {}
+} // namespace
+
+// CHECK-DAG: void @_ZL4FrobPN12_GLOBAL__N_14BillE(
+static void Frob(Bill *b) {
+  if (b)
+    b->F();
+}
+
+namespace N {
+// CHECK-DAG: void @_ZN1NL5innerEv(
+static void inner() {}
+// CHECK-DAG: @_ZN1NL1zE
+static int z = 3;
+} // namespace N
+
+// CHECK-DAG: void @_ZW1A6addsixv(
+void addsix() {
+  Frob(nullptr);
+  frob();
+  addone();
+  void(x + y + N::z);
+  N::inner();
+}