1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++14 | FileCheck --check-prefixes=CHECK,CXX14 %s
3
4 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv()
5 // CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
6 // CHECK-LABEL: define internal signext i8 @"_ZZZN19non_inline_function3fooEvENK3$_0clEiENKUlcE_clEc"(%class.anon
7 namespace non_inline_function {
foo()8 void foo() {
9 auto L = [](int a) {
10 return [](char b) {
11 return b;
12 };
13 };
14 L(3)('a');
15 }
16 }
17
18 namespace non_template {
19 struct L {
__anonbeacfc9a0302non_template::L20 int t = ([](int a) { return [](int b) { return b; };})(2)(3);
21 };
22 L l;
23 }
24
25 namespace lambdas_in_NSDMIs_template_class {
26 template<class T>
27 struct L {
__anonbeacfc9a0502lambdas_in_NSDMIs_template_class::L28 T t2 = ([](int a) { return [](int b) { return b; };})(T{})(T{});
29 };
30 L<int> l;
31 }
32
33 // CHECK-LABEL: define linkonce_odr i32 @_ZN15inline_function3fooEv
34
35 // CHECK-LABEL: define linkonce_odr void @_ZNK12non_template1L1tMUliE_clEi(%class.anon
36 // CHECK-LABEL: define linkonce_odr i32 @_ZZNK12non_template1L1tMUliE_clEiENKUliE_clEi(%class.anon
37
38
39 // CHECK-LABEL: define linkonce_odr void @_ZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEi(%class.anon
40 // CHECK-LABEL: define linkonce_odr i32 @_ZZNK32lambdas_in_NSDMIs_template_class1LIiEUliE_clEiENKUliE_clEi(%class.anon
41
42 // CHECK-LABEL: define linkonce_odr void @_ZZN15inline_function3fooEvENKUliE_clEi
43 // CHECK-LABEL: define linkonce_odr signext i8 @_ZZZN15inline_function3fooEvENKUliE_clEiENKUlcE_clEc
44 namespace inline_function {
foo()45 inline int foo() {
46 auto L = [](int a) {
47 return [](char b) {
48 return b;
49 };
50 };
51 L(3)('a');
52 }
53 int use = foo();
54 }
55
56 #if __cplusplus >= 201402L
57 // CXX14-LABEL: define internal void @"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_1EEDaS1_ENKUlvE_clEv"
58 namespace lambda_capture_in_generic_lambda {
foo()59 template <typename T> auto foo() {
60 return [](auto func) {
61 [func] { func(); }();
62 };
63 }
f()64 static void f() {
65 foo<int>()([] { });
66 }
f1()67 void f1() { f(); }
68 }
69 #endif
70