Debian Codegraph @

clang/test/Modules/cxx20-importing-function-bodies.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: cd %t
4 //
5 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm \
6 // RUN: -emit-module-interface -o %t/a.pcm
7 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \
8 // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm
9 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.cppm \
10 // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm
11 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.pcm \
12 // RUN: -fprebuilt-module-path=%t -emit-llvm -disable-llvm-passes -o - \
13 // RUN: | FileCheck %t/c.cppm
14 //
15 // Be sure that we keep the same behavior as if optization not enabled.
16 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/a.cppm \
17 // RUN: -emit-module-interface -o %t/a.pcm
18 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/b.cppm \
19 // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm
20 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/c.cppm \
21 // RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm
22 // RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/c.pcm \
23 // RUN: -fprebuilt-module-path=%t -emit-llvm -disable-llvm-passes \
24 // RUN: -o - | FileCheck %t/c.cppm
25
26 //--- a.cppm
27 export module a;
28 export int a() {
29 return 43;
30 }
31
32 template <int C>
33 int implicitly_inlined_template_function() {
34 return C;
35 }
36
37 inline int reachable_inlined_a() {
38 return 45;
39 }
40
41 int reachable_notinlined_a() {
42 return 46;
43 }
44
45 export inline int inlined_a() {
46 return 44 + reachable_inlined_a() +
47 reachable_notinlined_a() +
48 implicitly_inlined_template_function<47>();
49 }
50
51 //--- b.cppm
52 export module b;
53 export import a;
54 export int b() {
55 return 43 + a();
56 }
57 export inline int inlined_b() {
58 return 44 + inlined_a() + a();;
59 }
60
61 //--- c.cppm
62 export module c;
63 export import b;
64 export int c() {
65 return 43 + b() + a() + inlined_b() + inlined_a();
66 }
67
68 // CHECK: declare{{.*}}@_ZW1b1bv
69 // CHECK: declare{{.*}}@_ZW1a1av
70 // CHECK: define{{.*}}@_ZW1b9inlined_bv
71 // CHECK: define{{.*}}@_ZW1a9inlined_av
72 // CHECK: define{{.*}}@_ZW1a19reachable_inlined_av
73 // CHECK: declare{{.*}}@_ZW1a22reachable_notinlined_av
74 // CHECK: define{{.*}}@_ZW1a36implicitly_inlined_template_functionILi47EEiv