This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] libstdc++: Add operator-> support to unique_ptr xmethod.
- From: Doug Evans <dje at google dot com>
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Mon, 27 Apr 2015 16:12:26 -0700
- Subject: [PATCH] libstdc++: Add operator-> support to unique_ptr xmethod.
- Authentication-results: sourceware.org; auth=none
Hi.
This patch adds operator-> support to the unique_ptr xmethod.
Note: This patch assumes these two patches have been committed.
https://sourceware.org/ml/gdb-patches/2015-04/msg00947.html
https://gcc.gnu.org/ml/libstdc++/2015-04/msg00149.html
Regression tested on amd64-linux.
2015-04-27 Doug Evans <dje@google.com>
* python/libstdcxx/v6/xmethods.py (UniquePtrMethodsMatcher): Add
operator->.
* testsuite/libstdc++-xmethods/unique_ptr.cc: Add tests for operator->.
--- ./python/libstdcxx/v6/xmethods.py= 2015-04-27 10:46:52.000000000 -0700
+++ ./python/libstdcxx/v6/xmethods.py 2015-04-27 15:47:22.000000000 -0700
@@ -581,6 +581,7 @@ class UniquePtrMethodsMatcher(gdb.xmetho
matcher_name_prefix + 'unique_ptr')
self._method_dict = {
'get': LibStdCxxXMethod('get', UniquePtrGetWorker),
+ 'operator->': LibStdCxxXMethod('operator->', UniquePtrGetWorker),
'operator*': LibStdCxxXMethod('operator*', UniquePtrDerefWorker),
}
self.methods = [self._method_dict[m] for m in self._method_dict]
--- ./testsuite/libstdc++-xmethods/unique_ptr.cc= 2015-04-27 10:51:07.000000000 -0700
+++ ./testsuite/libstdc++-xmethods/unique_ptr.cc 2015-04-27 15:48:05.000000000 -0700
@@ -20,20 +20,36 @@
#include <memory>
+struct x_struct
+{
+ int y;
+};
+
int
main ()
{
int *i = new int;
*i = 10;
-
std::unique_ptr<int> p(i);
+ x_struct *x = new x_struct;
+ x->y = 23;
+ std::unique_ptr<x_struct> q(x);
+
// { dg-final { note-test *p 10 } }
// { dg-final { regexp-test p.get() 0x.* } }
// { dg-final { whatis-test *p int } }
// { dg-final { whatis-test p.get() int } }
+// { dg-final { note-test *q {\{y = 23\}} } }
+// { dg-final { regexp-test q.get() 0x.* } }
+// { dg-final { note-test q->y 23 } }
+
+// { dg-final { whatis-test *q x_struct } }
+// { dg-final { whatis-test q.get() x_struct } }
+// { dg-final { whatis-test q->y int } }
+
return 0; // Mark SPOT
}