1 // RUN: %clang_cc1 %s -triple=%itanium_abi_triple -O1 -emit-llvm -fextend-variable-liveness -o - | FileCheck %s 2 // Make sure we don't crash compiling a lambda that is not nested in a function. 3 // We also check that fake uses are properly issued in lambdas. 4 5 int glob; 6 7 extern int foo(); 8 9 struct S { 10 static const int a; 11 }; 12 13 const int S::a = [](int b) __attribute__((noinline)) { 14 return b * foo(); 15 } 16 (glob); 17 18 int func(int param) { 19 return ([=](int lambdaparm) __attribute__((noinline))->int { 20 int lambdalocal = lambdaparm * 2; 21 return lambdalocal; 22 }(glob)); 23 } 24 25 // We are looking for the first lambda's call operator, which should contain 26 // 2 fake uses, one for 'b' and one for its 'this' pointer (in that order). 27 // The mangled function name contains a $_0, followed by 'cl'. 28 // This lambda is an orphaned lambda, i.e. one without lexical parent. 29 // 30 // CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}} 31 // CHECK-NOT: ret 32 // CHECK: fake.use(i32 33 // CHECK-NOT: ret 34 // CHECK: fake.use(ptr 35 36 // The second lambda. We are looking for 3 fake uses. 37 // CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}} 38 // CHECK-NOT: ret 39 // CHECK: fake.use(i32 40 // CHECK-NOT: ret 41 // CHECK: fake.use(i32 42 // CHECK-NOT: ret 43 // CHECK: fake.use(ptr 44