[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 7 19:31:44 PST 2024


================
@@ -0,0 +1,50 @@
+// REQUIRES: !system-windows
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/layer1.cppm -triple %itanium_abi_triple \
+// RUN:     -emit-module-interface -o %t/foo-layer1.pcm
+// RUN: %clang_cc1 -std=c++20 %t/layer2.cppm -triple %itanium_abi_triple  \
+// RUN:     -emit-module-interface -fmodule-file=foo:layer1=%t/foo-layer1.pcm \
+// RUN:     -o %t/foo-layer2.pcm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer1.pcm -S -emit-llvm -o - | FileCheck %t/layer1.cppm
+// RUN: %clang_cc1 -std=c++20 %t/foo-layer2.pcm -S -emit-llvm -o - \
+// RUN:     -fmodule-file=foo:layer1=%t/foo-layer1.pcm | FileCheck %t/layer2.cppm
+
+//--- layer1.cppm
+export module foo:layer1;
+struct Fruit {
+    virtual ~Fruit() = default;
+    virtual void eval() = 0;
+};
+struct Banana : public Fruit {
+    Banana() {}
+    void eval() override;
+};
+
----------------
ChuanqiXu9 wrote:

Great suggestion. I caught another bug after I removed `Banana`: previously we would only generate vtable if it is used. And my draft to fix that is https://github.com/ChuanqiXu9/llvm-project/commit/f6a22849bb410532c60dca4453fd2b0b71da3994. It touches Sema and Serializer. So I feel it is a little bit complex even if it is small. Personally, I prefer to separate that into 2 patches later instead of combining everything in the current single patch. How do you feel about the direction? @dwblaikie @rjmccall 

https://github.com/llvm/llvm-project/pull/75912


More information about the cfe-commits mailing list