Debian Codegraph @

clang/test/Modules/lambda-merge.cpp

raw
1 // RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
2
3 #pragma clang module build A
4 module A {}
5 #pragma clang module contents
6 #pragma clang module begin A
7 template<typename T> T f(T v) {
8 v();
9 return v;
10 }
11 inline auto g() {
12 int n = 0;
13 return f([=] { return n; });
14 }
15
16 template<typename T> constexpr T f2(T v) {
17 v();
18 return v;
19 }
20 constexpr auto g2() {
21 int n = 0;
22 return f2([=] { return n; });
23 }
24 #pragma clang module end
25 #pragma clang module endbuild
26
27 #pragma clang module build B
28 module B {}
29 #pragma clang module contents
30 #pragma clang module begin B
31 template<typename T> T f(T v) {
32 v();
33 return v;
34 }
35 inline auto g() {
36 int n = 0;
37 return f([=] { return n; });
38 }
39
40 template<typename T> constexpr T f2(T v) {
41 v();
42 return v;
43 }
44 constexpr auto g2() {
45 int n = 0;
46 return f2([=] { return n; });
47 }
48 #pragma clang module end
49 #pragma clang module endbuild
50
51 #pragma clang module import A
52 #pragma clang module import B
53
54 // CHECK: define {{.*}}use_g
55 int use_g() {
56 return g()();
57 }
58
59 static_assert(g2()() == 0);