1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
4 auto unused
= [](int i
) { return i
+1; };
6 // CHECK: @used = internal global
7 auto used
= [](int i
) { return i
+1; };
10 // CHECK: @cvar ={{.*}} global
11 extern "C" auto cvar
= []{};
13 // CHECK-LABEL: define{{.*}} i32 @_Z9ARBSizeOfi(i32
14 int ARBSizeOf(int n
) {
15 typedef double(T
)[8][n
];
16 using TT
= double[8][n
];
18 typedef double(T1
)[8][n
];
19 using TT1
= double[8][n
];
20 return [&n
]() -> int {
21 typedef double(T2
)[8][n
];
22 using TT2
= double[8][n
];
23 return sizeof(T
) + sizeof(T1
) + sizeof(T2
) + sizeof(TT
) + sizeof(TT1
) + sizeof(TT2
);
28 // CHECK-LABEL: define internal noundef i32 @"_ZZ9ARBSizeOfiENK3$_0clEv"
30 int a() { return []{ return 1; }(); }
31 // CHECK-LABEL: define{{.*}} i32 @_Z1av
32 // CHECK: call noundef i32 @"_ZZ1avENK3$_0clEv"
33 // CHECK-LABEL: define internal noundef i32 @"_ZZ1avENK3$_0clEv"
36 int b(int x
) { return [x
]{return x
;}(); }
37 // CHECK-LABEL: define{{.*}} i32 @_Z1bi
39 // CHECK: load i32, ptr
41 // CHECK: call noundef i32 @"_ZZ1biENK3$_0clEv"
42 // CHECK-LABEL: define internal noundef i32 @"_ZZ1biENK3$_0clEv"
43 // CHECK: load i32, ptr
46 int c(int x
) { return [&x
]{return x
;}(); }
47 // CHECK-LABEL: define{{.*}} i32 @_Z1ci
50 // CHECK: call noundef i32 @"_ZZ1ciENK3$_0clEv"
51 // CHECK-LABEL: define internal noundef i32 @"_ZZ1ciENK3$_0clEv"
52 // CHECK: load ptr, ptr
53 // CHECK: load i32, ptr
56 struct D
{ D(); D(const D
&); int x
; };
57 int d(int x
) { D y
[10]; return [x
,y
] { return y
[x
].x
; }(); }
59 // CHECK-LABEL: define{{.*}} i32 @_Z1di
60 // CHECK: call void @_ZN1DC1Ev
62 // CHECK: call void @_ZN1DC1ERKS_
63 // CHECK: icmp eq i64 %{{.*}}, 10
65 // CHECK: call noundef i32 @"_ZZ1diENK3$_0clEv"
66 // CHECK-LABEL: define internal noundef i32 @"_ZZ1diENK3$_0clEv"
67 // CHECK: load i32, ptr
68 // CHECK: load i32, ptr
71 struct E
{ E(); E(const E
&); ~E(); int x
; };
72 int e(E a
, E b
, bool cond
) { return [a
,b
,cond
](){ return (cond
? a
: b
).x
; }(); }
73 // CHECK-LABEL: define{{.*}} i32 @_Z1e1ES_b
74 // CHECK: call void @_ZN1EC1ERKS_
75 // CHECK: invoke void @_ZN1EC1ERKS_
76 // CHECK: invoke noundef i32 @"_ZZ1e1ES_bENK3$_0clEv"
77 // CHECK: call void @"_ZZ1e1ES_bEN3$_0D1Ev"
78 // CHECK: call void @"_ZZ1e1ES_bEN3$_0D1Ev"
80 // CHECK-LABEL: define internal noundef i32 @"_ZZ1e1ES_bENK3$_0clEv"
82 // CHECK: load i32, ptr
86 // CHECK-LABEL: define{{.*}} void @_Z1fv()
87 // CHECK: @"_ZZ1fvENK3$_0cvPFiiiEEv"
88 // CHECK-NEXT: store ptr
89 // CHECK-NEXT: ret void
90 int (*fp
)(int, int) = [](int x
, int y
){ return x
+ y
; };
96 // CHECK-LABEL: define internal noundef i32 @"_ZZ1gvENK3$_0clEv"(
98 // CHECK: load i32, ptr @_ZL1k,
99 return [] { return r
; } ();
103 // CHECK: [[ARRVAL:%[0-9a-zA-Z]*]] = load i32, ptr @_ZZ14staticarrayrefvE5array, align 4
104 // CHECK-NEXT: store i32 [[ARRVAL]]
105 void staticarrayref(){
106 static int array
[] = {};
108 int (&xxx
)[0] = array
;
113 // CHECK-LABEL: define internal noundef ptr @"_ZZ11PR22071_funvENK3$_0clEv"
114 // CHECK: ret ptr @PR22071_var
117 constexpr int &y
= PR22071_var
;
118 return [&] { return &y
; }();
124 ~Temp() noexcept(false);
128 A(const A
&a
, const Temp
&temp
= Temp());
132 void after_init() noexcept
;
134 // CHECK-LABEL: define{{.*}} void @_ZN7pr285954testEv()
136 // CHECK: %[[SRC:.*]] = alloca [3 x [5 x %[[A:.*]]]], align 1
139 // Skip over the initialization loop.
140 // CHECK: call {{.*}}after_init
143 // CHECK: %[[DST_0:.*]] = getelementptr {{.*}} ptr %[[DST:.*]], i64 0, i64 0
145 // CHECK: %[[I:.*]] = phi i64 [ 0, %{{.*}} ], [ %[[I_NEXT:.*]], {{.*}} ]
146 // CHECK: %[[DST_I:.*]] = getelementptr {{.*}} ptr %[[DST_0]], i64 %[[I]]
147 // CHECK: %[[SRC_I:.*]] = getelementptr {{.*}} ptr %[[SRC]], i64 0, i64 %[[I]]
149 // CHECK: %[[DST_I_0:.*]] = getelementptr {{.*}} ptr %[[DST_I]], i64 0, i64 0
151 // CHECK: %[[J:.*]] = phi i64 [ 0, %{{.*}} ], [ %[[J_NEXT:.*]], {{.*}} ]
152 // CHECK: %[[DST_I_J:.*]] = getelementptr {{.*}} ptr %[[DST_I_0]], i64 %[[J]]
153 // CHECK: %[[SRC_I_J:.*]] = getelementptr {{.*}} ptr %[[SRC_I]], i64 0, i64 %[[J]]
155 // CHECK: invoke void @_ZN7pr285954TempC1Ev
156 // CHECK: invoke void @_ZN7pr285951AC1ERKS0_RKNS_4TempE
157 // CHECK: invoke void @_ZN7pr285954TempD1Ev
159 // CHECK: add nuw i64 %[[J]], 1
163 // CHECK: add nuw i64 %[[I]], 1
171 // CHECK: br label %[[CLEANUP:.*]]{{$}}
173 // CHECK: invoke void @_ZN7pr285954TempD1Ev
174 // CHECK: br label %[[CLEANUP]]
176 // CHECK: [[CLEANUP]]:
177 // CHECK: icmp eq ptr %[[DST_0]], %[[DST_I_J]]
178 // CHECK: %[[T0:.*]] = phi ptr
179 // CHECK: %[[T1:.*]] = getelementptr inbounds %[[A]], ptr %[[T0]], i64 -1
180 // CHECK: call void @_ZN7pr285951AD1Ev(ptr {{[^,]*}} %[[T1]])
181 // CHECK: icmp eq ptr %[[T1]], %[[DST_0]]
186 // CHECK-LABEL: define internal void @"_ZZ1e1ES_bEN3$_0D2Ev"
188 // CHECK-LABEL: define internal noundef i32 @"_ZZ1fvEN3$_08__invokeEii"
190 // CHECK-NEXT: store i32
191 // CHECK-NEXT: load i32, ptr
192 // CHECK-NEXT: load i32, ptr
193 // CHECK-NEXT: call noundef i32 @"_ZZ1fvENK3$_0clEii"
194 // CHECK-NEXT: ret i32
196 // CHECK-LABEL: define internal void @"_ZZ1hvEN3$_08__invokeEv"(ptr noalias sret(%struct.A) align 1 %agg.result) {{.*}} {
197 // CHECK: call void @"_ZZ1hvENK3$_0clEv"(ptr sret(%struct.A) align 1 %agg.result,
198 // CHECK-NEXT: ret void
201 A (*h
)() = [] { return A(); };
205 void nestedCapture () {
209 ^{ XXX k
= localKey
; };
214 // Ensure we don't assert here.
215 struct CaptureArrayAndThis
{
216 CaptureArrayAndThis() {
217 char array
[] = "floop";
220 } capture_array_and_this
;