blob: e27d4d315267f799ced5e22ad015301291e4c7b7 [file] [log] [blame]
Reid Kleckner496ecab2017-09-15 21:59:39 +00001// This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
2// of a string object occurs in C++.
3//
Adrian Prantla0de3a82017-12-07 19:40:31 +00004// RUN: %clangxx -O0 -fno-exceptions %target_itanium_abi_host_triple %s -o %t.out -g
Reid Kleckner496ecab2017-09-15 21:59:39 +00005// RUN: %test_debuginfo %s %t.out
Adrian Prantla0de3a82017-12-07 19:40:31 +00006// RUN: %clangxx -O1 -fno-exceptions %target_itanium_abi_host_triple %s -o %t.out -g
Mike Edwards4a343382017-09-19 14:51:37 +00007// RUN: %test_debuginfo %s %t.out
Reid Kleckner496ecab2017-09-15 21:59:39 +00008//
9// PR34513
10
11struct string {
12 string() {}
13 string(int i) : i(i) {}
14 ~string() {}
15 int i = 0;
16};
17string get_string() {
18 string unused;
19 string result = 3;
Amy Huang7fac5c82019-06-20 17:15:21 +000020 // DEBUGGER: break 21
Reid Kleckner496ecab2017-09-15 21:59:39 +000021 return result;
22}
Amy Huang7fac5c82019-06-20 17:15:21 +000023void some_function(int) {}
24struct string2 {
25 string2() = default;
26 string2(string2 &&other) { i = other.i; }
27 int i;
28};
29string2 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}
38int main() {
39 get_string();
40 get_string2();
41}
Reid Kleckner496ecab2017-09-15 21:59:39 +000042
43// DEBUGGER: r
44// DEBUGGER: print result.i
45// CHECK: = 3
Amy Huang7fac5c82019-06-20 17:15:21 +000046// DEBUGGER: c
47// DEBUGGER: print result.i
48// CHECK: = 5