blob: ba8d9d42f6f404bb38b2a65520517b5c59ab7194 [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
Adrian Prantl559c6e12019-06-27 20:38:37 +000010volatile int sideeffect = 0;
11void __attribute__((noinline)) stop() { sideeffect++; }
Reid Kleckner496ecab2017-09-15 21:59:39 +000012
13struct string {
14 string() {}
15 string(int i) : i(i) {}
16 ~string() {}
17 int i = 0;
18};
19string get_string() {
20 string unused;
21 string result = 3;
Adrian Prantl559c6e12019-06-27 20:38:37 +000022 // DEBUGGER: break 23
Adrian Prantl8ac899c2019-06-26 20:04:09 +000023 stop();
Reid Kleckner496ecab2017-09-15 21:59:39 +000024 return result;
25}
Amy Huang7fac5c82019-06-20 17:15:21 +000026void some_function(int) {}
27struct string2 {
28 string2() = default;
29 string2(string2 &&other) { i = other.i; }
30 int i;
31};
32string2 get_string2() {
33 string2 result;
34 result.i = 5;
35 some_function(result.i);
36 // Test that the debugger can get the value of result after another
37 // function is called.
Adrian Prantl559c6e12019-06-27 20:38:37 +000038 // DEBUGGER: break 39
Adrian Prantl8ac899c2019-06-26 20:04:09 +000039 stop();
Amy Huang7fac5c82019-06-20 17:15:21 +000040 return result;
41}
42int main() {
43 get_string();
44 get_string2();
45}
Reid Kleckner496ecab2017-09-15 21:59:39 +000046
47// DEBUGGER: r
48// DEBUGGER: print result.i
49// CHECK: = 3
Amy Huang7fac5c82019-06-20 17:15:21 +000050// DEBUGGER: c
51// DEBUGGER: print result.i
52// CHECK: = 5