diff options
author | Vedant Kumar <vsk@apple.com> | 2018-08-16 23:05:15 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-08-16 23:05:15 +0000 |
commit | c8becc0ed7eb7d0efb6d899e819f572c99d17fa6 (patch) | |
tree | 64021b4bac8f5b5045a4c2b84f987a20f74daea9 /debuginfo-tests | |
parent | 088f08b8831c87c73f6c314e6ddfe449d91631e9 (diff) |
Add a basic integration test for C++ smart pointers
Check that the debugger can pretty-print unique_ptr and shared_ptr when
passed as a function argument.
rdar://42314305
Diffstat (limited to 'debuginfo-tests')
-rw-r--r-- | debuginfo-tests/smart-ptr-1.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/debuginfo-tests/smart-ptr-1.cpp b/debuginfo-tests/smart-ptr-1.cpp new file mode 100644 index 00000000000..3be26b9ef97 --- /dev/null +++ b/debuginfo-tests/smart-ptr-1.cpp @@ -0,0 +1,41 @@ +// RUN: %clangxx -std=c++14 %target_itanium_abi_host_triple -g %s -o %t.O0.out +// RUN: %test_debuginfo %s %t.O0.out + +#include <memory> + +static volatile int sink; + +static void use_shared_ptr(std::shared_ptr<int> ptr) { + // DEBUGGER: break 10 + sink = *ptr; +} + +static void use_unique_ptr(std::unique_ptr<int> ptr) { + // DEBUGGER: break 15 + sink = *ptr; +} + +int main() { + auto sp_1 = std::make_shared<int>(1234); + use_shared_ptr(sp_1); + + auto up_1 = std::make_unique<int>(5678); + use_unique_ptr(std::move(up_1)); + + return 0; +} + +// DEBUGGER: r + +// (at line 10) +// DEBUGGER: p ptr +// CHECK: shared_ptr<int> +// CHECK-SAME: 1234 + +// DEBUGGER: c + +// (at line 16) +// DEBUGGER: p ptr +// CHECK: unique_ptr<int> +// TODO: lldb's unique_ptr data formatter doesn't pretty-print its wrapped +// object. |