1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -g | FileCheck %s
2 
__anon1e3f47610102(int i) 3 auto var = [](int i) { return i+1; };
4 void *use = &var;
5 
__anon1e3f47610202null6 extern "C" auto cvar = []{};
7 
a()8 int a() { return []{ return 1; }(); }
9 
b(int x)10 int b(int x) { return [x]{return x;}(); }
11 
c(int x)12 int c(int x) { return [&x]{return x;}(); }
13 
14 struct D { D(); D(const D&); int x; };
d(int x)15 int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }
16 
17 // Randomness for file. -- 6
18 // CHECK: [[FILE:.*]] = !MDFile(filename: "{{.*}}debug-lambda-expressions.cpp",
19 
20 // CHECK: ![[INT:[0-9]+]] = !MDBasicType(name: "int"
21 
22 // A: 10
23 // CHECK: ![[A_FUNC:.*]] = !MDSubprogram(name: "a"{{.*}}, line: [[A_LINE:[0-9]+]]{{.*}}, isDefinition: true
24 
25 // B: 14
26 // CHECK: ![[B_FUNC:.*]] = !MDSubprogram(name: "b"{{.*}}, line: [[B_LINE:[0-9]+]]{{.*}}, isDefinition: true
27 
28 // C: 17
29 // CHECK: ![[C_FUNC:.*]] = !MDSubprogram(name: "c"{{.*}}, line: [[C_LINE:[0-9]+]]{{.*}}, isDefinition: true
30 
31 // D: 18
32 // CHECK: ![[D_FUNC:.*]] = !MDSubprogram(name: "d"{{.*}}, line: [[D_LINE:[0-9]+]]{{.*}}, isDefinition: true
33 
34 
35 // Back to A. -- 78
36 // CHECK: ![[LAM_A:.*]] = !MDCompositeType(tag: DW_TAG_class_type{{.*}}, scope: ![[A_FUNC]]{{.*}}, line: [[A_LINE]],
37 // CHECK-SAME:                             elements: ![[LAM_A_ARGS:[0-9]+]]
38 // CHECK: ![[LAM_A_ARGS]] = !{![[CON_LAM_A:[0-9]+]]}
39 // CHECK: ![[CON_LAM_A]] = !MDSubprogram(name: "operator()"
40 // CHECK-SAME:                           scope: ![[LAM_A]]
41 // CHECK-SAME:                           line: [[A_LINE]]
42 // CHECK-SAME:                           DIFlagPublic
43 
44 // Back to B. -- 67
45 // CHECK: ![[LAM_B:.*]] = !MDCompositeType(tag: DW_TAG_class_type{{.*}}, scope: ![[B_FUNC]]{{.*}}, line: [[B_LINE]],
46 // CHECK-SAME:                             elements: ![[LAM_B_ARGS:[0-9]+]]
47 // CHECK: ![[LAM_B_ARGS]] = !{![[CAP_B:[0-9]+]], ![[CON_LAM_B:[0-9]+]]}
48 // CHECK: ![[CAP_B]] = !MDDerivedType(tag: DW_TAG_member, name: "x"
49 // CHECK-SAME:                        scope: ![[LAM_B]]
50 // CHECK-SAME:                        line: [[B_LINE]],
51 // CHECK-SAME:                        baseType: ![[INT]]
52 // CHECK: ![[CON_LAM_B]] = !MDSubprogram(name: "operator()"
53 // CHECK-SAME:                           scope: ![[LAM_B]]
54 // CHECK-SAME:                           line: [[B_LINE]]
55 // CHECK-SAME:                           DIFlagPublic
56 
57 // Back to C. -- 55
58 // CHECK: ![[LAM_C:.*]] = !MDCompositeType(tag: DW_TAG_class_type{{.*}}, scope: ![[C_FUNC]]{{.*}}, line: [[C_LINE]],
59 // CHECK-SAME:                             elements: ![[LAM_C_ARGS:[0-9]+]]
60 // CHECK: ![[LAM_C_ARGS]] = !{![[CAP_C:[0-9]+]], ![[CON_LAM_C:[0-9]+]]}
61 // CHECK: ![[CAP_C]] = !MDDerivedType(tag: DW_TAG_member, name: "x"
62 // CHECK-SAME:                        scope: ![[LAM_C]]
63 // CHECK-SAME:                        line: [[C_LINE]],
64 // CHECK-SAME:                        baseType: ![[TYPE_C_x:[0-9]+]]
65 // CHECK: ![[TYPE_C_x]] = !MDDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT]]
66 // CHECK: ![[CON_LAM_C]] = !MDSubprogram(name: "operator()"
67 // CHECK-SAME:                           scope: ![[LAM_C]]
68 // CHECK-SAME:                           line: [[C_LINE]]
69 // CHECK-SAME:                           DIFlagPublic
70 
71 // Back to D. -- 24
72 // CHECK: ![[LAM_D:.*]] = !MDCompositeType(tag: DW_TAG_class_type{{.*}}, scope: ![[D_FUNC]]{{.*}}, line: [[D_LINE]],
73 // CHECK-SAME:                             elements: ![[LAM_D_ARGS:[0-9]+]]
74 // CHECK: ![[LAM_D_ARGS]] = !{![[CAP_D_X:[0-9]+]], ![[CAP_D_Y:[0-9]+]], ![[CON_LAM_D:[0-9]+]]}
75 // CHECK: ![[CAP_D_X]] = !MDDerivedType(tag: DW_TAG_member, name: "x"
76 // CHECK-SAME:                          scope: ![[LAM_D]]
77 // CHECK-SAME:                          line: [[D_LINE]],
78 // CHECK: ![[CAP_D_Y]] = !MDDerivedType(tag: DW_TAG_member, name: "y"
79 // CHECK-SAME:                          scope: ![[LAM_D]]
80 // CHECK-SAME:                          line: [[D_LINE]],
81 // CHECK: ![[CON_LAM_D]] = !MDSubprogram(name: "operator()"
82 // CHECK-SAME:                           scope: ![[LAM_D]]
83 // CHECK-SAME:                           line: [[D_LINE]]
84 // CHECK-SAME:                           DIFlagPublic
85 
86 // CVAR:
87 // CHECK: !MDGlobalVariable(name: "cvar"
88 // CHECK-SAME:              line: [[CVAR_LINE:[0-9]+]]
89 // CHECK-SAME:              type: ![[CVAR_T:[0-9]+]]
90 // CHECK: ![[CVAR_T]] = !MDCompositeType(tag: DW_TAG_class_type
91 // CHECK-SAME:                           line: [[CVAR_LINE]],
92 // CHECK-SAME:                           elements: ![[CVAR_ARGS:[0-9]+]]
93 // CHECK: ![[CVAR_ARGS]] = !{!{{[0-9]+}}}
94 
95 // VAR:
96 // CHECK: !MDGlobalVariable(name: "var"
97 // CHECK-SAME:              line: [[VAR_LINE:[0-9]+]]
98 // CHECK-SAME:              type: ![[VAR_T:[0-9]+]]
99 // CHECK: ![[VAR_T]] = !MDCompositeType(tag: DW_TAG_class_type
100 // CHECK-SAME:                          line: [[VAR_LINE]],
101 // CHECK-SAME:                          elements: ![[VAR_ARGS:[0-9]+]]
102 // CHECK: ![[VAR_ARGS]] = !{!{{[0-9]+}}}
103