[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / cross-project-tests / debuginfo-tests / dexter-tests / optnone-simple-functions.cpp
blob83a655b36e2be9b6c090fadd4952334d7187a026
1 // RUN: %dexter --fail-lt 1.0 -w \
2 // RUN: --builder 'clang' --debugger 'lldb' \
3 // RUN: --cflags "-O2 -g" -- %s
4 // RUN: %dexter --fail-lt 1.0 -w \
5 // RUN: --builder 'clang' --debugger 'lldb' \
6 // RUN: --cflags "-O0 -g" -- %s
8 // REQUIRES: lldb, D136396
9 // UNSUPPORTED: system-windows
11 //// Check that the debugging experience with __attribute__((optnone)) at O2
12 //// matches O0. Test simple functions performing simple arithmetic
13 //// operations and small loops.
15 __attribute__((optnone))
16 int test1(int test1_a, int test1_b) {
17 int test1_result = 0;
18 // DexLabel('test1_start')
19 test1_result = test1_a + test1_b; // DexExpectStepOrder(1)
20 return test1_result; // DexExpectStepOrder(2)
21 // DexLabel('test1_end')
23 // DexExpectWatchValue('test1_a', 3, from_line=ref('test1_start'), to_line=ref('test1_end'))
24 // DexExpectWatchValue('test1_b', 4, from_line=ref('test1_start'), to_line=ref('test1_end'))
25 // DexExpectWatchValue('test1_result', 0, 7, from_line=ref('test1_start'), to_line=ref('test1_end'))
27 __attribute__((optnone))
28 int test2(int test2_a, int test2_b) {
29 int test2_result = test2_a + test2_a + test2_a + test2_a; // DexExpectStepOrder(3)
30 // DexLabel('test2_start')
31 return test2_a << 2; // DexExpectStepOrder(4)
32 // DexLabel('test2_end')
34 // DexExpectWatchValue('test2_a', 1, from_line=ref('test2_start'), to_line=ref('test2_end'))
35 // DexExpectWatchValue('test2_b', 2, from_line=ref('test2_start'), to_line=ref('test2_end'))
36 // DexExpectWatchValue('test2_result', 4, from_line=ref('test2_start'), to_line=ref('test2_end'))
38 __attribute__((optnone))
39 int test3(int test3_a, int test3_b) {
40 int test3_temp1 = 0, test3_temp2 = 0;
41 // DexLabel('test3_start')
42 test3_temp1 = test3_a + 5; // DexExpectStepOrder(5)
43 test3_temp2 = test3_b + 5; // DexExpectStepOrder(6)
44 if (test3_temp1 > test3_temp2) { // DexExpectStepOrder(7)
45 test3_temp1 *= test3_temp2; // DexUnreachable()
47 return test3_temp1; // DexExpectStepOrder(8)
48 // DexLabel('test3_end')
50 // DexExpectWatchValue('test3_a', 5, from_line=ref('test3_start'), to_line=ref('test3_end'))
51 // DexExpectWatchValue('test3_b', 6, from_line=ref('test3_start'), to_line=ref('test3_end'))
52 // DexExpectWatchValue('test3_temp1', 0, 10, from_line=ref('test3_start'), to_line=ref('test3_end'))
53 // DexExpectWatchValue('test3_temp2', 0, 11, from_line=ref('test3_start'), to_line=ref('test3_end'))
55 unsigned num_iterations = 4;
57 __attribute__((optnone))
58 int test4(int test4_a, int test4_b) {
59 int val1 = 0, val2 = 0;
60 // DexLabel('test4_start')
62 val1 = (test4_a > test4_b) ? test4_a : test4_b; // DexExpectStepOrder(9)
63 val2 = val1;
64 val2 += val1; // DexExpectStepOrder(10)
66 for (unsigned i=0; i != num_iterations; ++i) { // DexExpectStepOrder(11, 13, 15, 17, 19)
67 val1--;
68 val2 += i;
69 if (val2 % 2 == 0) // DexExpectStepOrder(12, 14, 16, 18)
70 val2 /= 2;
73 return (val1 > val2) ? val2 : val1; // DexExpectStepOrder(20)
74 // DexLabel('test4_end')
76 // DexExpectWatchValue('test4_a', 1, from_line=ref('test4_start'), to_line=ref('test4_end'))
77 // DexExpectWatchValue('test4_b', 9, from_line=ref('test4_start'), to_line=ref('test4_end'))
78 // DexExpectWatchValue('val1', 0, 9, 8, 7, 6, 5, from_line=ref('test4_start'), to_line=ref('test4_end'))
79 // DexExpectWatchValue('val2', 0, 9, 18, 9, 10, 5, 7, 10, 5, 9, from_line=ref('test4_start'), to_line=ref('test4_end'))
81 __attribute__((optnone))
82 int test5(int test5_val) {
83 int c = 1; // DexExpectStepOrder(21)
84 // DexLabel('test5_start')
85 if (test5_val) // DexExpectStepOrder(22)
86 c = 5; // DexExpectStepOrder(23)
87 return c ? test5_val : test5_val; // DexExpectStepOrder(24)
88 // DexLabel('test5_end')
90 // DexExpectWatchValue('test5_val', 7, from_line=ref('test5_start'), to_line=ref('test5_end'))
91 // DexExpectWatchValue('c', 1, 5, from_line=ref('test5_start'), to_line=ref('test5_end'))
93 __attribute__((optnone))
94 int main() {
95 int main_result = 0;
96 // DexLabel('main_start')
97 main_result = test1(3,4);
98 main_result += test2(1,2);
99 main_result += test3(5,6);
100 main_result += test4(1,9);
101 main_result += test5(7);
102 return main_result;
103 // DexLabel('main_end')
105 // DexExpectWatchValue('main_result', 0, 7, 11, 21, 26, 33, from_line=ref('main_start'), to_line=ref('main_end'))