Skip to content

Commit e3f5269

Browse files
committed
[NFC] [C++20] [Modules] Add a test for no transitive changes
1 parent 241a56d commit e3f5269

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Testing that adding a new line in a module interface unit won't cause the BMI
2+
// of consuming module unit changes.
3+
//
4+
// RUN: rm -rf %t
5+
// RUN: split-file %s %t
6+
//
7+
// RUN: %clang_cc1 -std=c++20 %t/A.part.cppm -emit-reduced-module-interface -o %t/A-part.pcm
8+
//
9+
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.v0.pcm \
10+
// RUN: -fprebuilt-module-path=%t
11+
// RUN: %clang_cc1 -std=c++20 %t/A.v1.cppm -emit-reduced-module-interface -o %t/A.v1.pcm \
12+
// RUN: -fprebuilt-module-path=%t
13+
//
14+
// The BMI may not be the same since the source location differs.
15+
// RUN: not diff %t/A.pcm %t/A.v1.pcm &> /dev/null
16+
//
17+
// The BMI of B shouldn't change since all the locations remain the same.
18+
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v0.pcm \
19+
// RUN: -o %t/B.pcm -fprebuilt-module-path=%t
20+
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v1.pcm \
21+
// RUN: -o %t/B.v1.pcm -fprebuilt-module-path=%t
22+
// RUN: diff %t/B.v1.pcm %t/B.pcm &> /dev/null
23+
//
24+
// The BMI of C may change since the locations for instantiations changes.
25+
// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v0.pcm \
26+
// RUN: -o %t/C.pcm -fprebuilt-module-path=%t
27+
// RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v1.pcm \
28+
// RUN: -o %t/C.v1.pcm -fprebuilt-module-path=%t
29+
// RUN: diff %t/C.v1.pcm %t/C.pcm &> /dev/null
30+
31+
//--- A.part.cppm
32+
export module A:part;
33+
export template <class T>
34+
struct C {
35+
T func() {
36+
return T(43);
37+
}
38+
};
39+
export int funcA() {
40+
return 43;
41+
}
42+
43+
//--- A.cppm
44+
export module A;
45+
export import :part;
46+
47+
//--- A.v1.cppm
48+
export module A;
49+
50+
export import :part;
51+
52+
//--- B.cppm
53+
export module B;
54+
import A;
55+
56+
export int funcB() {
57+
return funcA();
58+
}
59+
60+
//--- C.cppm
61+
export module C;
62+
import A;
63+
export inline void testD() {
64+
C<int> c;
65+
c.func();
66+
}

0 commit comments

Comments
 (0)