2012-12-01 09:01:09 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
|
2012-02-14 11:07:59 +08:00
|
|
|
|
2012-08-07 12:16:51 +08:00
|
|
|
// CHECK-NOT: @unused
|
|
|
|
auto unused = [](int i) { return i+1; };
|
|
|
|
|
|
|
|
// CHECK: @used = internal global
|
|
|
|
auto used = [](int i) { return i+1; };
|
|
|
|
void *use = &used;
|
2012-02-21 04:05:29 +08:00
|
|
|
|
2012-02-21 04:47:06 +08:00
|
|
|
// CHECK: @cvar = global
|
|
|
|
extern "C" auto cvar = []{};
|
|
|
|
|
2012-02-14 11:07:59 +08:00
|
|
|
int a() { return []{ return 1; }(); }
|
|
|
|
// CHECK: define i32 @_Z1av
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: call i32 @"_ZZ1avENK3$_0clEv"
|
|
|
|
// CHECK: define internal i32 @"_ZZ1avENK3$_0clEv"
|
2012-02-14 11:07:59 +08:00
|
|
|
// CHECK: ret i32 1
|
|
|
|
|
|
|
|
int b(int x) { return [x]{return x;}(); }
|
|
|
|
// CHECK: define i32 @_Z1bi
|
|
|
|
// CHECK: store i32
|
|
|
|
// CHECK: load i32*
|
|
|
|
// CHECK: store i32
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: call i32 @"_ZZ1biENK3$_1clEv"
|
|
|
|
// CHECK: define internal i32 @"_ZZ1biENK3$_1clEv"
|
2012-02-14 11:07:59 +08:00
|
|
|
// CHECK: load i32*
|
|
|
|
// CHECK: ret i32
|
|
|
|
|
|
|
|
int c(int x) { return [&x]{return x;}(); }
|
|
|
|
// CHECK: define i32 @_Z1ci
|
|
|
|
// CHECK: store i32
|
|
|
|
// CHECK: store i32*
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: call i32 @"_ZZ1ciENK3$_2clEv"
|
|
|
|
// CHECK: define internal i32 @"_ZZ1ciENK3$_2clEv"
|
2012-02-14 11:07:59 +08:00
|
|
|
// CHECK: load i32**
|
|
|
|
// CHECK: load i32*
|
|
|
|
// CHECK: ret i32
|
|
|
|
|
|
|
|
struct D { D(); D(const D&); int x; };
|
|
|
|
int d(int x) { D y[10]; [x,y] { return y[x].x; }(); }
|
|
|
|
|
|
|
|
// CHECK: define i32 @_Z1di
|
|
|
|
// CHECK: call void @_ZN1DC1Ev
|
|
|
|
// CHECK: icmp ult i64 %{{.*}}, 10
|
|
|
|
// CHECK: call void @_ZN1DC1ERKS_
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: call i32 @"_ZZ1diENK3$_3clEv"
|
|
|
|
// CHECK: define internal i32 @"_ZZ1diENK3$_3clEv"
|
2012-02-14 11:07:59 +08:00
|
|
|
// CHECK: load i32*
|
|
|
|
// CHECK: load i32*
|
|
|
|
// CHECK: ret i32
|
|
|
|
|
|
|
|
struct E { E(); E(const E&); ~E(); int x; };
|
|
|
|
int e(E a, E b, bool cond) { [a,b,cond](){ return (cond ? a : b).x; }(); }
|
|
|
|
// CHECK: define i32 @_Z1e1ES_b
|
|
|
|
// CHECK: call void @_ZN1EC1ERKS_
|
|
|
|
// CHECK: invoke void @_ZN1EC1ERKS_
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: invoke i32 @"_ZZ1e1ES_bENK3$_4clEv"
|
|
|
|
// CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev"
|
|
|
|
// CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev"
|
2012-02-17 11:02:34 +08:00
|
|
|
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: define internal i32 @"_ZZ1e1ES_bENK3$_4clEv"
|
2012-02-14 11:07:59 +08:00
|
|
|
// CHECK: trunc i8
|
|
|
|
// CHECK: load i32*
|
|
|
|
// CHECK: ret i32
|
2012-02-17 11:02:34 +08:00
|
|
|
|
|
|
|
void f() {
|
|
|
|
// CHECK: define void @_Z1fv()
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: @"_ZZ1fvENK3$_5cvPFiiiEEv"
|
2012-02-17 11:02:34 +08:00
|
|
|
// CHECK-NEXT: store i32 (i32, i32)*
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
int (*fp)(int, int) = [](int x, int y){ return x + y; };
|
|
|
|
}
|
|
|
|
|
2012-10-20 09:38:33 +08:00
|
|
|
static int k;
|
|
|
|
int g() {
|
|
|
|
int &r = k;
|
|
|
|
// CHECK: define internal i32 @"_ZZ1gvENK3$_6clEv"(
|
|
|
|
// CHECK-NOT: }
|
|
|
|
// CHECK: load i32* @_ZL1k,
|
|
|
|
return [] { return r; } ();
|
|
|
|
};
|
|
|
|
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: define internal i32 @"_ZZ1fvEN3$_58__invokeEii"
|
2012-02-17 11:02:34 +08:00
|
|
|
// CHECK: store i32
|
|
|
|
// CHECK-NEXT: store i32
|
|
|
|
// CHECK-NEXT: load i32*
|
|
|
|
// CHECK-NEXT: load i32*
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK-NEXT: call i32 @"_ZZ1fvENK3$_5clEii"
|
2012-02-17 11:02:34 +08:00
|
|
|
// CHECK-NEXT: ret i32
|
|
|
|
|
2012-02-21 12:17:39 +08:00
|
|
|
// CHECK: define internal void @"_ZZ1e1ES_bEN3$_4D2Ev"
|
2012-12-01 09:01:09 +08:00
|
|
|
|
|
|
|
// <rdar://problem/12778708>
|
|
|
|
struct XXX {};
|
|
|
|
void nestedCapture () {
|
|
|
|
XXX localKey;
|
|
|
|
^() {
|
|
|
|
[&]() {
|
|
|
|
^{ XXX k = localKey; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|