[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / cross-project-tests / debuginfo-tests / llgdb-tests / nrvo-string.cpp
blob988c4ae2232aee7becf262345cfdf02c516f8ad9
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 // RUN: %clangxx -O0 -fno-exceptions %target_itanium_abi_host_triple %s -o %t.out -g
5 // RUN: %test_debuginfo %s %t.out
6 // RUN: %clangxx -O1 -fno-exceptions %target_itanium_abi_host_triple %s -o %t.out -g
7 // RUN: %test_debuginfo %s %t.out
8 // XFAIL: !system-darwin && gdb-clang-incompatibility
9 // PR34513
10 volatile int sideeffect = 0;
11 void __attribute__((noinline)) stop() { sideeffect++; }
13 struct string {
14 string() {}
15 string(int i) : i(i) {}
16 ~string() {}
17 int i = 0;
19 string __attribute__((noinline)) get_string() {
20 string unused;
21 string result = 3;
22 // DEBUGGER: break 23
23 stop();
24 return result;
26 void some_function(int) {}
27 struct string2 {
28 string2() = default;
29 string2(string2 &&other) { i = other.i; }
30 int i;
32 string2 __attribute__((noinline)) 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.
38 // DEBUGGER: break 39
39 stop();
40 return result;
42 int main() {
43 get_string();
44 get_string2();
47 // DEBUGGER: r
48 // DEBUGGER: print result.i
49 // CHECK: = 3
50 // DEBUGGER: c
51 // DEBUGGER: print result.i
52 // CHECK: = 5