1 // This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
2 // of a string object occurs in C++.
3 //
4 // REQUIRES: system-windows
5 //
6 // RUN: %dexter --fail-lt 1.0 -w --builder 'clang-cl_vs2015' \
7 // RUN:      --debugger 'dbgeng' --cflags '/Z7 /Zi' --ldflags '/Z7 /Zi' -- %s
8 
9 struct string {
10   string() {}
11   string(int i) : i(i) {}
12   ~string() {}
13   int i = 0;
14 };
15 string get_string() {
16   string unused;
17   string result = 3;
18   return result; // DexLabel('readresult1')
19 }
20 void some_function(int) {}
21 struct string2 {
22   string2() = default;
23   string2(string2 &&other) { i = other.i; }
24   int i;
25 };
26 string2 get_string2() {
27   string2 result;
28   result.i = 5;
29   some_function(result.i);
30   // Test that the debugger can get the value of result after another
31   // function is called.
32   return result; // DexLabel('readresult2')
33 }
34 int main() {
35   get_string();
36   get_string2();
37 }
38 
39 // DexExpectWatchValue('result.i', 3, on_line=ref('readresult1'))
40 // DexExpectWatchValue('result.i', 5, on_line=ref('readresult2'))
41