Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s |
| 2 | |
Douglas Gregor | ee18803 | 2012-02-20 20:05:29 +0000 | [diff] [blame] | 3 | // CHECK: @var = internal global |
| 4 | auto var = [](int i) { return i+1; }; |
| 5 | |
Douglas Gregor | fa07ab5 | 2012-02-20 20:47:06 +0000 | [diff] [blame] | 6 | // CHECK: @cvar = global |
| 7 | extern "C" auto cvar = []{}; |
| 8 | |
Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 9 | int a() { return []{ return 1; }(); } |
| 10 | // CHECK: define i32 @_Z1av |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 11 | // CHECK: call i32 @"_ZZ1avENK3$_0clEv" |
| 12 | // CHECK: define internal i32 @"_ZZ1avENK3$_0clEv" |
Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 13 | // CHECK: ret i32 1 |
| 14 | |
| 15 | int b(int x) { return [x]{return x;}(); } |
| 16 | // CHECK: define i32 @_Z1bi |
| 17 | // CHECK: store i32 |
| 18 | // CHECK: load i32* |
| 19 | // CHECK: store i32 |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 20 | // CHECK: call i32 @"_ZZ1biENK3$_1clEv" |
| 21 | // CHECK: define internal i32 @"_ZZ1biENK3$_1clEv" |
Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 22 | // CHECK: load i32* |
| 23 | // CHECK: ret i32 |
| 24 | |
| 25 | int c(int x) { return [&x]{return x;}(); } |
| 26 | // CHECK: define i32 @_Z1ci |
| 27 | // CHECK: store i32 |
| 28 | // CHECK: store i32* |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 29 | // CHECK: call i32 @"_ZZ1ciENK3$_2clEv" |
| 30 | // CHECK: define internal i32 @"_ZZ1ciENK3$_2clEv" |
Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 31 | // CHECK: load i32** |
| 32 | // CHECK: load i32* |
| 33 | // CHECK: ret i32 |
| 34 | |
| 35 | struct D { D(); D(const D&); int x; }; |
| 36 | int d(int x) { D y[10]; [x,y] { return y[x].x; }(); } |
| 37 | |
| 38 | // CHECK: define i32 @_Z1di |
| 39 | // CHECK: call void @_ZN1DC1Ev |
| 40 | // CHECK: icmp ult i64 %{{.*}}, 10 |
| 41 | // CHECK: call void @_ZN1DC1ERKS_ |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 42 | // CHECK: call i32 @"_ZZ1diENK3$_3clEv" |
| 43 | // CHECK: define internal i32 @"_ZZ1diENK3$_3clEv" |
Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 44 | // CHECK: load i32* |
| 45 | // CHECK: load i32* |
| 46 | // CHECK: ret i32 |
| 47 | |
| 48 | struct E { E(); E(const E&); ~E(); int x; }; |
| 49 | int e(E a, E b, bool cond) { [a,b,cond](){ return (cond ? a : b).x; }(); } |
| 50 | // CHECK: define i32 @_Z1e1ES_b |
| 51 | // CHECK: call void @_ZN1EC1ERKS_ |
| 52 | // CHECK: invoke void @_ZN1EC1ERKS_ |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 53 | // CHECK: invoke i32 @"_ZZ1e1ES_bENK3$_4clEv" |
| 54 | // CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev" |
| 55 | // CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev" |
Douglas Gregor | 27dd7d9 | 2012-02-17 03:02:34 +0000 | [diff] [blame] | 56 | |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 57 | // CHECK: define internal i32 @"_ZZ1e1ES_bENK3$_4clEv" |
Eli Friedman | 8656855 | 2012-02-14 03:07:59 +0000 | [diff] [blame] | 58 | // CHECK: trunc i8 |
| 59 | // CHECK: load i32* |
| 60 | // CHECK: ret i32 |
Douglas Gregor | 27dd7d9 | 2012-02-17 03:02:34 +0000 | [diff] [blame] | 61 | |
| 62 | void f() { |
| 63 | // CHECK: define void @_Z1fv() |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 64 | // CHECK: @"_ZZ1fvENK3$_5cvPFiiiEEv" |
Douglas Gregor | 27dd7d9 | 2012-02-17 03:02:34 +0000 | [diff] [blame] | 65 | // CHECK-NEXT: store i32 (i32, i32)* |
| 66 | // CHECK-NEXT: ret void |
| 67 | int (*fp)(int, int) = [](int x, int y){ return x + y; }; |
| 68 | } |
| 69 | |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 70 | // CHECK: define internal i32 @"_ZZ1fvEN3$_58__invokeEii" |
Douglas Gregor | 27dd7d9 | 2012-02-17 03:02:34 +0000 | [diff] [blame] | 71 | // CHECK: store i32 |
| 72 | // CHECK-NEXT: store i32 |
| 73 | // CHECK-NEXT: load i32* |
| 74 | // CHECK-NEXT: load i32* |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 75 | // CHECK-NEXT: call i32 @"_ZZ1fvENK3$_5clEii" |
Douglas Gregor | 27dd7d9 | 2012-02-17 03:02:34 +0000 | [diff] [blame] | 76 | // CHECK-NEXT: ret i32 |
| 77 | |
Douglas Gregor | 5878cbc | 2012-02-21 04:17:39 +0000 | [diff] [blame] | 78 | // CHECK: define internal void @"_ZZ1e1ES_bEN3$_4D2Ev" |