[clang] c21790d - [NFC] [C++20] [Modules] Tests that the duplicated declarations in GMF
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 17 01:04:00 PDT 2023
Author: Chuanqi Xu
Date: 2023-03-17T15:58:10+08:00
New Revision: c21790d02302ca0c00fab15c49c14db6514ceb5e
URL: https://github.com/llvm/llvm-project/commit/c21790d02302ca0c00fab15c49c14db6514ceb5e
DIFF: https://github.com/llvm/llvm-project/commit/c21790d02302ca0c00fab15c49c14db6514ceb5e.diff
LOG: [NFC] [C++20] [Modules] Tests that the duplicated declarations in GMF
won't get generated again
As the test shows, we don't want to see the specialized function bodies
if it is already contained in the imported modules. So we can save a lot
of compiling time then.
Added:
clang/test/Modules/no-duplicate-codegen-in-GMF.cppm
Modified:
Removed:
################################################################################
diff --git a/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm b/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm
new file mode 100644
index 000000000000..e4d06415fabd
--- /dev/null
+++ b/clang/test/Modules/no-duplicate-codegen-in-GMF.cppm
@@ -0,0 +1,40 @@
+// Tests that the declaration won't get emitted after being merged.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.cppm -emit-module-interface -o %t/B.pcm \
+// RUN: -fprebuilt-module-path=%t
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.pcm -S -emit-llvm -o - | FileCheck %t/B.cppm
+
+//--- foo.h
+
+template <class T>
+class foo {
+public:
+ T value;
+ T GetValue() { return value; }
+};
+
+template class foo<int>;
+
+//--- A.cppm
+module;
+#include "foo.h"
+export module A;
+export using ::foo;
+
+//--- B.cppm
+module;
+#include "foo.h"
+export module B;
+import A;
+export using ::foo;
+export int B() {
+ foo<int> f;
+ return f.GetValue();
+}
+
+// CHECK-NOT: define{{.*}}@_ZN3fooIiE8GetValueEv
More information about the cfe-commits
mailing list