[Github] Label lldb-dap PRs (#125139)
[llvm-project.git] / clang / test / CodeGen / fake-use-lambda.cpp
blobaaf25caab6a39f57f87ed9f80afdef0dc264f01c
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.
5 int glob;
7 extern int foo();
9 struct S {
10 static const int a;
13 const int S::a = [](int b) __attribute__((noinline)) {
14 return b * foo();
16 (glob);
18 int func(int param) {
19 return ([=](int lambdaparm) __attribute__((noinline))->int {
20 int lambdalocal = lambdaparm * 2;
21 return lambdalocal;
22 }(glob));
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.
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
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