Reid Kleckner | 496ecab | 2017-09-15 21:59:39 +0000 | [diff] [blame] | 1 | // This ensures that DW_OP_deref is inserted when necessary, such as when NRVO |
| 2 | // of a string object occurs in C++. |
| 3 | // |
Adrian Prantl | a0de3a8 | 2017-12-07 19:40:31 +0000 | [diff] [blame] | 4 | // RUN: %clangxx -O0 -fno-exceptions %target_itanium_abi_host_triple %s -o %t.out -g |
Reid Kleckner | 496ecab | 2017-09-15 21:59:39 +0000 | [diff] [blame] | 5 | // RUN: %test_debuginfo %s %t.out |
Adrian Prantl | a0de3a8 | 2017-12-07 19:40:31 +0000 | [diff] [blame] | 6 | // RUN: %clangxx -O1 -fno-exceptions %target_itanium_abi_host_triple %s -o %t.out -g |
Mike Edwards | 4a34338 | 2017-09-19 14:51:37 +0000 | [diff] [blame] | 7 | // RUN: %test_debuginfo %s %t.out |
Reid Kleckner | 496ecab | 2017-09-15 21:59:39 +0000 | [diff] [blame] | 8 | // |
| 9 | // PR34513 |
| 10 | |
| 11 | struct string { |
| 12 | string() {} |
| 13 | string(int i) : i(i) {} |
| 14 | ~string() {} |
| 15 | int i = 0; |
| 16 | }; |
| 17 | string get_string() { |
| 18 | string unused; |
| 19 | string result = 3; |
Amy Huang | 7fac5c8 | 2019-06-20 17:15:21 +0000 | [diff] [blame^] | 20 | // DEBUGGER: break 21 |
Reid Kleckner | 496ecab | 2017-09-15 21:59:39 +0000 | [diff] [blame] | 21 | return result; |
| 22 | } |
Amy Huang | 7fac5c8 | 2019-06-20 17:15:21 +0000 | [diff] [blame^] | 23 | void some_function(int) {} |
| 24 | struct string2 { |
| 25 | string2() = default; |
| 26 | string2(string2 &&other) { i = other.i; } |
| 27 | int i; |
| 28 | }; |
| 29 | string2 get_string2() { |
| 30 | string2 result; |
| 31 | result.i = 5; |
| 32 | some_function(result.i); |
| 33 | // Test that the debugger can get the value of result after another |
| 34 | // function is called. |
| 35 | // DEBUGGER: break 35 |
| 36 | return result; |
| 37 | } |
| 38 | int main() { |
| 39 | get_string(); |
| 40 | get_string2(); |
| 41 | } |
Reid Kleckner | 496ecab | 2017-09-15 21:59:39 +0000 | [diff] [blame] | 42 | |
| 43 | // DEBUGGER: r |
| 44 | // DEBUGGER: print result.i |
| 45 | // CHECK: = 3 |
Amy Huang | 7fac5c8 | 2019-06-20 17:15:21 +0000 | [diff] [blame^] | 46 | // DEBUGGER: c |
| 47 | // DEBUGGER: print result.i |
| 48 | // CHECK: = 5 |