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$_1clEv"
33 // CHECK-LABEL: define internal noundef i32 @"_ZZ1avENK3$_1clEv"
36 int b(int x
) { return [x
]{return x
;}(); }
37 // CHECK-LABEL: define{{.*}} i32 @_Z1bi
39 // CHECK: load i32, i32*
41 // CHECK: call noundef i32 @"_ZZ1biENK3$_2clEv"
42 // CHECK-LABEL: define internal noundef i32 @"_ZZ1biENK3$_2clEv"
43 // CHECK: load i32, i32*
46 int c(int x
) { return [&x
]{return x
;}(); }
47 // CHECK-LABEL: define{{.*}} i32 @_Z1ci
50 // CHECK: call noundef i32 @"_ZZ1ciENK3$_3clEv"
51 // CHECK-LABEL: define internal noundef i32 @"_ZZ1ciENK3$_3clEv"
52 // CHECK: load i32*, i32**
53 // CHECK: load i32, i32*
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$_4clEv"
66 // CHECK-LABEL: define internal noundef i32 @"_ZZ1diENK3$_4clEv"
67 // CHECK: load i32, i32*
68 // CHECK: load i32, i32*
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$_5clEv"
77 // CHECK: call void @"_ZZ1e1ES_bEN3$_5D1Ev"
78 // CHECK: call void @"_ZZ1e1ES_bEN3$_5D1Ev"
80 // CHECK-LABEL: define internal noundef i32 @"_ZZ1e1ES_bENK3$_5clEv"
82 // CHECK: load i32, i32*
86 // CHECK-LABEL: define{{.*}} void @_Z1fv()
87 // CHECK: @"_ZZ1fvENK3$_6cvPFiiiEEv"
88 // CHECK-NEXT: store i32 (i32, i32)*
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$_7clEv"(
98 // CHECK: load i32, i32* @_ZL1k,
99 return [] { return r
; } ();
103 // CHECK: [[ARRVAL:%[0-9a-zA-Z]*]] = load i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @_ZZ14staticarrayrefvE5array, i64 0, i64 0), 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 i32* @"_ZZ11PR22071_funvENK3$_9clEv"
114 // CHECK: ret i32* @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 {{.*}} [3 x [5 x %[[A]]]]* %[[DST:.*]], i64 0, i64 0
145 // CHECK: %[[I:.*]] = phi i64 [ 0, %{{.*}} ], [ %[[I_NEXT:.*]], {{.*}} ]
146 // CHECK: %[[DST_I:.*]] = getelementptr {{.*}} [5 x %[[A]]]* %[[DST_0]], i64 %[[I]]
147 // CHECK: %[[SRC_I:.*]] = getelementptr {{.*}} [3 x [5 x %[[A]]]]* %[[SRC]], i64 0, i64 %[[I]]
149 // CHECK: %[[DST_I_0:.*]] = getelementptr {{.*}} [5 x %[[A]]]* %[[DST_I]], i64 0, i64 0
151 // CHECK: %[[J:.*]] = phi i64 [ 0, %{{.*}} ], [ %[[J_NEXT:.*]], {{.*}} ]
152 // CHECK: %[[DST_I_J:.*]] = getelementptr {{.*}} %[[A]]* %[[DST_I_0]], i64 %[[J]]
153 // CHECK: %[[DST_0_0:.*]] = bitcast [5 x %[[A]]]* %[[DST_0]] to %[[A]]*
154 // CHECK: %[[SRC_I_J:.*]] = getelementptr {{.*}} [5 x %[[A]]]* %[[SRC_I]], i64 0, i64 %[[J]]
156 // CHECK: invoke void @_ZN7pr285954TempC1Ev
157 // CHECK: invoke void @_ZN7pr285951AC1ERKS0_RKNS_4TempE
158 // CHECK: invoke void @_ZN7pr285954TempD1Ev
160 // CHECK: add nuw i64 %[[J]], 1
164 // CHECK: add nuw i64 %[[I]], 1
172 // CHECK: br label %[[CLEANUP:.*]]{{$}}
174 // CHECK: invoke void @_ZN7pr285954TempD1Ev
175 // CHECK: br label %[[CLEANUP]]
177 // CHECK: [[CLEANUP]]:
178 // CHECK: icmp eq %[[A]]* %[[DST_0_0]], %[[DST_I_J]]
179 // CHECK: %[[T0:.*]] = phi %[[A]]*
180 // CHECK: %[[T1:.*]] = getelementptr inbounds %[[A]], %[[A]]* %[[T0]], i64 -1
181 // CHECK: call void @_ZN7pr285951AD1Ev(%[[A]]* {{[^,]*}} %[[T1]])
182 // CHECK: icmp eq %[[A]]* %[[T1]], %[[DST_0_0]]
187 // CHECK-LABEL: define internal void @"_ZZ1e1ES_bEN3$_5D2Ev"
189 // CHECK-LABEL: define internal noundef i32 @"_ZZ1fvEN3$_68__invokeEii"
191 // CHECK-NEXT: store i32
192 // CHECK-NEXT: load i32, i32*
193 // CHECK-NEXT: load i32, i32*
194 // CHECK-NEXT: call noundef i32 @"_ZZ1fvENK3$_6clEii"
195 // CHECK-NEXT: ret i32
197 // CHECK-LABEL: define internal void @"_ZZ1hvEN4$_118__invokeEv"(%struct.A* noalias sret(%struct.A) align 1 %agg.result) {{.*}} {
198 // CHECK: call void @"_ZZ1hvENK4$_11clEv"(%struct.A* sret(%struct.A) align 1 %agg.result,
199 // CHECK-NEXT: ret void
202 A (*h
)() = [] { return A(); };
205 // <rdar://problem/12778708>
207 void nestedCapture () {
211 ^{ XXX k
= localKey
; };
216 // Ensure we don't assert here.
217 struct CaptureArrayAndThis
{
218 CaptureArrayAndThis() {
219 char array
[] = "floop";
222 } capture_array_and_this
;