Skip to content

Commit c21790d

Browse files
committed
[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.
1 parent ee6d07f commit c21790d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Tests that the declaration won't get emitted after being merged.
2+
//
3+
// RUN: rm -rf %t
4+
// RUN: mkdir -p %t
5+
// RUN: split-file %s %t
6+
//
7+
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/A.cppm -emit-module-interface -o %t/A.pcm
8+
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.cppm -emit-module-interface -o %t/B.pcm \
9+
// RUN: -fprebuilt-module-path=%t
10+
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/B.pcm -S -emit-llvm -o - | FileCheck %t/B.cppm
11+
12+
//--- foo.h
13+
14+
template <class T>
15+
class foo {
16+
public:
17+
T value;
18+
T GetValue() { return value; }
19+
};
20+
21+
template class foo<int>;
22+
23+
//--- A.cppm
24+
module;
25+
#include "foo.h"
26+
export module A;
27+
export using ::foo;
28+
29+
//--- B.cppm
30+
module;
31+
#include "foo.h"
32+
export module B;
33+
import A;
34+
export using ::foo;
35+
export int B() {
36+
foo<int> f;
37+
return f.GetValue();
38+
}
39+
40+
// CHECK-NOT: define{{.*}}@_ZN3fooIiE8GetValueEv

0 commit comments

Comments
 (0)