[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / commands / expression / expr_inside_lambda / main.cpp
blob3808f3616bffc74b8c80d8b88ac68c1e5a8de0f1
1 #include <cassert>
2 #include <cstdio>
4 namespace {
5 int global_var = -5;
6 } // namespace
8 struct Baz {
9 virtual ~Baz() = default;
11 virtual int baz_virt() = 0;
13 int base_base_var = 12;
16 struct Bar : public Baz {
17 virtual ~Bar() = default;
19 virtual int baz_virt() override {
20 base_var = 10;
21 return 1;
24 int base_var = 15;
27 struct Foo : public Bar {
28 int class_var = 9;
29 int shadowed = -137;
30 int *class_ptr;
32 virtual ~Foo() = default;
34 virtual int baz_virt() override {
35 shadowed = -1;
36 return 2;
39 void method() {
40 int local_var = 137;
41 int shadowed;
42 class_ptr = &local_var;
43 auto lambda = [&shadowed, this, &local_var,
44 local_var_copy = local_var]() mutable {
45 int lambda_local_var = 5;
46 shadowed = 5;
47 class_var = 109;
48 --base_var;
49 --base_base_var;
50 std::puts("break here");
52 auto nested_lambda = [this, &lambda_local_var, local_var] {
53 std::puts("break here");
54 lambda_local_var = 0;
57 nested_lambda();
58 --local_var_copy;
59 std::puts("break here");
61 struct LocalLambdaClass {
62 int lambda_class_local = -12345;
63 Foo *outer_ptr;
65 void inner_method() {
66 auto lambda = [this] {
67 std::puts("break here");
68 lambda_class_local = -2;
69 outer_ptr->class_var *= 2;
72 lambda();
76 LocalLambdaClass l;
77 l.outer_ptr = this;
78 l.inner_method();
80 lambda();
83 void non_capturing_method() {
84 int local = 5;
85 int local2 = 10;
87 class_var += [=] {
88 std::puts("break here");
89 return local + local2;
90 }();
94 int main() {
95 Foo f;
96 f.method();
97 f.non_capturing_method();
98 return global_var;