xref: /llvm-project/lldb/test/API/functionalities/optimized_code/main.cpp (revision 99a05667217162029d1de84d4a49d041c06be175)
1 // This is a regression test that checks whether lldb can inspect the variables
2 // in this program without triggering an ASan exception.
3 
use(int x)4 __attribute__((noinline, optnone)) int use(int x) { return x; }
5 
6 volatile int sink;
7 
8 struct S1 {
9   int f1;
10   int *f2;
11 };
12 
13 struct S2 {
14   char a = 0;
15   char b = 0;
16   int pad = 0;
S2S217   S2(int x) {
18     a = x & 0xff;
19     b = x & 0xff00;
20   }
21 };
22 
main()23 int main() {
24   S1 v1;
25   v1.f1 = sink;
26   v1.f2 = nullptr;
27   sink++; //% self.expect("frame variable v1", substrs=["S1"])
28   S2 v2(v1.f1);
29   sink += use(v2.a); //% self.expect("frame variable v2", substrs=["S2"])
30   sink += use(v2.pad); //% self.expect("frame variable v2", substrs=["S2"])
31   return 0;
32 }
33