Debian Codegraph @

clang/test/Modules/no-transitive-source-location-change.cppm

raw
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.cppm -emit-reduced-module-interface -o %t/A.pcm
8 // RUN: %clang_cc1 -std=c++20 %t/A.v1.cppm -emit-reduced-module-interface -o %t/A.v1.pcm
9 //
10 // The BMI may not be the same since the source location differs.
11 // RUN: not diff %t/A.pcm %t/A.v1.pcm &> /dev/null
12 //
13 // The BMI of B shouldn't change since all the locations remain the same.
14 // RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.pcm \
15 // RUN: -o %t/B.pcm
16 // RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v1.pcm \
17 // RUN: -o %t/B.v1.pcm
18 // RUN: diff %t/B.v1.pcm %t/B.pcm &> /dev/null
19 //
20 // The BMI of C may change since the locations for instantiations changes.
21 // RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.pcm \
22 // RUN: -o %t/C.pcm
23 // RUN: %clang_cc1 -std=c++20 %t/C.cppm -emit-reduced-module-interface -fmodule-file=A=%t/A.v1.pcm \
24 // RUN: -o %t/C.v1.pcm
25 // RUN: not diff %t/C.v1.pcm %t/C.pcm &> /dev/null
26
27 //--- A.cppm
28 export module A;
29 export template <class T>
30 struct C {
31 T func() {
32 return T(43);
33 }
34 };
35 export int funcA() {
36 return 43;
37 }
38
39 //--- A.v1.cppm
40 export module A;
41
42 export template <class T>
43 struct C {
44 T func() {
45 return T(43);
46 }
47 };
48 export int funcA() {
49 return 43;
50 }
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 }