summaryrefslogtreecommitdiffstats
path: root/debuginfo-tests/win_cdb/nrvo.cpp
blob: 5712118b39cf34d63d36f989ec9164a88b8fd361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
// of a string object occurs in C++.
//
// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
//

struct string {
  string() {}
  string(int i) : i(i) {}
  ~string() {}
  int i = 0;
};
string get_string() {
  string unused;
  string result = 3;
  __debugbreak();
  return result;
}
void some_function(int) {}
struct string2 {
  string2() = default;
  string2(string2 &&other) { i = other.i; }
  int i;
};
string2 get_string2() {
  string2 result;
  result.i = 5;
  some_function(result.i);
  // Test that the debugger can get the value of result after another
  // function is called.
  __debugbreak();
  return result;
}
int main() {
  get_string();
  get_string2();
}

// DEBUGGER: g
// DEBUGGER: ?? result
// CHECK: struct string *
// CHECK:    +0x000 i : 0n3
// DEBUGGER: g
// DEBUGGER: ?? result
// CHECK: struct string2 *
// CHECK:    +0x000 i : 0n5
// DEBUGGER: q
OpenPOWER on IntegriCloud