diff options
| author | Amy Huang <akhuang@google.com> | 2019-06-20 17:15:21 +0000 |
|---|---|---|
| committer | Amy Huang <akhuang@google.com> | 2019-06-20 17:15:21 +0000 |
| commit | 7fac5c8d940c91e1e7b8b704186b4649170b029f (patch) | |
| tree | bf0d0c3cbafe46a0b6ddfa6873fbc6349d275dcb /debuginfo-tests | |
| parent | 01511192b23f531b8d378fa522d46647ce7b41a7 (diff) | |
| download | bcm5719-llvm-7fac5c8d940c91e1e7b8b704186b4649170b029f.tar.gz bcm5719-llvm-7fac5c8d940c91e1e7b8b704186b4649170b029f.zip | |
Store a pointer to the return value in a static alloca and let the debugger use that
as the variable address for NRVO variables.
Subscribers: hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D63361
llvm-svn: 363952
Diffstat (limited to 'debuginfo-tests')
| -rw-r--r-- | debuginfo-tests/nrvo-string.cpp | 25 | ||||
| -rw-r--r-- | debuginfo-tests/win_cdb/nrvo.cpp | 49 |
2 files changed, 72 insertions, 2 deletions
diff --git a/debuginfo-tests/nrvo-string.cpp b/debuginfo-tests/nrvo-string.cpp index 18acebb0e6d..e27d4d31526 100644 --- a/debuginfo-tests/nrvo-string.cpp +++ b/debuginfo-tests/nrvo-string.cpp @@ -17,11 +17,32 @@ struct string { string get_string() { string unused; string result = 3; -// DEBUGGER: break 21 + // DEBUGGER: break 21 return result; } -int main() { get_string(); } +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. + // DEBUGGER: break 35 + return result; +} +int main() { + get_string(); + get_string2(); +} // DEBUGGER: r // DEBUGGER: print result.i // CHECK: = 3 +// DEBUGGER: c +// DEBUGGER: print result.i +// CHECK: = 5 diff --git a/debuginfo-tests/win_cdb/nrvo.cpp b/debuginfo-tests/win_cdb/nrvo.cpp new file mode 100644 index 00000000000..5712118b39c --- /dev/null +++ b/debuginfo-tests/win_cdb/nrvo.cpp @@ -0,0 +1,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 |

