PR libstdc++/80276 fix pretty printers for array smart pointers
PR libstdc++/80276 * python/libstdcxx/v6/printers.py (SharedPointerPrinter) (UniquePointerPrinter): Print correct template argument, not type of the pointer. (TemplateTypePrinter._recognizer.recognize): Handle failure to lookup a type. * testsuite/libstdc++-prettyprinters/cxx11.cc: Test unique_ptr of array type. * testsuite/libstdc++-prettyprinters/cxx17.cc: Test shared_ptr and weak_ptr of array types. From-SVN: r256400
This commit is contained in:
parent
ee6019ce5d
commit
8273aa77d4
|
@ -1,3 +1,16 @@
|
||||||
|
2018-01-09 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
PR libstdc++/80276
|
||||||
|
* python/libstdcxx/v6/printers.py (SharedPointerPrinter)
|
||||||
|
(UniquePointerPrinter): Print correct template argument, not type of
|
||||||
|
the pointer.
|
||||||
|
(TemplateTypePrinter._recognizer.recognize): Handle failure to lookup
|
||||||
|
a type.
|
||||||
|
* testsuite/libstdc++-prettyprinters/cxx11.cc: Test unique_ptr of
|
||||||
|
array type.
|
||||||
|
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test shared_ptr and
|
||||||
|
weak_ptr of array types.
|
||||||
|
|
||||||
2018-01-09 François Dumont <fdumont@gcc.gnu.org>
|
2018-01-09 François Dumont <fdumont@gcc.gnu.org>
|
||||||
|
|
||||||
PR libstdc++/83709
|
PR libstdc++/83709
|
||||||
|
|
|
@ -150,7 +150,7 @@ class SharedPointerPrinter:
|
||||||
state = 'expired, weak count %d' % weakcount
|
state = 'expired, weak count %d' % weakcount
|
||||||
else:
|
else:
|
||||||
state = 'use count %d, weak count %d' % (usecount, weakcount - 1)
|
state = 'use count %d, weak count %d' % (usecount, weakcount - 1)
|
||||||
return '%s<%s> (%s)' % (self.typename, str(self.pointer.type.target().strip_typedefs()), state)
|
return '%s<%s> (%s)' % (self.typename, str(self.val.type.template_argument(0)), state)
|
||||||
|
|
||||||
class UniquePointerPrinter:
|
class UniquePointerPrinter:
|
||||||
"Print a unique_ptr"
|
"Print a unique_ptr"
|
||||||
|
@ -169,7 +169,7 @@ class UniquePointerPrinter:
|
||||||
return SmartPtrIterator(self.pointer)
|
return SmartPtrIterator(self.pointer)
|
||||||
|
|
||||||
def to_string (self):
|
def to_string (self):
|
||||||
return ('std::unique_ptr<%s>' % (str(self.pointer.type.target())))
|
return ('std::unique_ptr<%s>' % (str(self.val.type.template_argument(0))))
|
||||||
|
|
||||||
def get_value_from_aligned_membuf(buf, valtype):
|
def get_value_from_aligned_membuf(buf, valtype):
|
||||||
"""Returns the value held in a __gnu_cxx::__aligned_membuf."""
|
"""Returns the value held in a __gnu_cxx::__aligned_membuf."""
|
||||||
|
@ -1328,9 +1328,13 @@ class TemplateTypePrinter(object):
|
||||||
for i, sub in enumerate(subs):
|
for i, sub in enumerate(subs):
|
||||||
if ('{%d}' % (i+1)) in self.subst:
|
if ('{%d}' % (i+1)) in self.subst:
|
||||||
# apply recognizers to subgroup
|
# apply recognizers to subgroup
|
||||||
|
try:
|
||||||
|
subtype = gdb.lookup_type(sub)
|
||||||
|
except gdb.error:
|
||||||
|
continue
|
||||||
rep = gdb.types.apply_type_recognizers(
|
rep = gdb.types.apply_type_recognizers(
|
||||||
gdb.types.get_type_recognizers(),
|
gdb.types.get_type_recognizers(),
|
||||||
gdb.lookup_type(sub))
|
subtype)
|
||||||
if rep:
|
if rep:
|
||||||
subs[i] = rep
|
subs[i] = rep
|
||||||
subs = [None] + subs
|
subs = [None] + subs
|
||||||
|
|
|
@ -131,6 +131,12 @@ main()
|
||||||
std::unique_ptr<datum> &ruptr = uptr;
|
std::unique_ptr<datum> &ruptr = uptr;
|
||||||
// { dg-final { regexp-test ruptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } }
|
// { dg-final { regexp-test ruptr {std::unique_ptr.datum. = {get\(\) = 0x.*}} } }
|
||||||
|
|
||||||
|
using data = datum[];
|
||||||
|
std::unique_ptr<data> arrptr (new datum[2]);
|
||||||
|
// { dg-final { regexp-test arrptr {std::unique_ptr.datum \[\]. = {get\(\) = 0x.*}} } }
|
||||||
|
std::unique_ptr<data>& rarrptr = arrptr;
|
||||||
|
// { dg-final { regexp-test rarrptr {std::unique_ptr.datum \[\]. = {get\(\) = 0x.*}} } }
|
||||||
|
|
||||||
ExTuple tpl(6,7);
|
ExTuple tpl(6,7);
|
||||||
// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } }
|
// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } }
|
||||||
ExTuple &rtpl = tpl;
|
ExTuple &rtpl = tpl;
|
||||||
|
@ -144,6 +150,7 @@ main()
|
||||||
use(eums);
|
use(eums);
|
||||||
use(uoms);
|
use(uoms);
|
||||||
use(uptr->s);
|
use(uptr->s);
|
||||||
|
use(arrptr[0].s);
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <memory>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using std::any;
|
using std::any;
|
||||||
|
@ -37,6 +38,8 @@ using std::variant;
|
||||||
using std::string_view;
|
using std::string_view;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::unordered_set;
|
using std::unordered_set;
|
||||||
|
using std::shared_ptr;
|
||||||
|
using std::weak_ptr;
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
|
@ -100,6 +103,18 @@ main()
|
||||||
unordered_set<int>::node_type n3 = s.extract(3);
|
unordered_set<int>::node_type n3 = s.extract(3);
|
||||||
// { dg-final { note-test n1 {node handle for unordered set with element = {3}}}}
|
// { dg-final { note-test n1 {node handle for unordered set with element = {3}}}}
|
||||||
|
|
||||||
|
shared_ptr<int[]> p(new int[1]);
|
||||||
|
weak_ptr wp = p;
|
||||||
|
weak_ptr wp2 = p;
|
||||||
|
// { dg-final { regexp-test p {std::shared_ptr.int \[\]. \(use count 1, weak count 2\) = {get\(\) = 0x.*}} } }
|
||||||
|
// { dg-final { regexp-test wp {std::weak_ptr.int \[\]. \(use count 1, weak count 2\) = {get\(\) = 0x.*}} } }
|
||||||
|
|
||||||
|
shared_ptr<int[2]> q(new int[2]);
|
||||||
|
shared_ptr q2 = q;
|
||||||
|
weak_ptr wq = q;
|
||||||
|
// { dg-final { regexp-test q {std::shared_ptr.int \[2\]. \(use count 2, weak count 1\) = {get\(\) = 0x.*}} } }
|
||||||
|
// { dg-final { regexp-test wq {std::weak_ptr.int \[2\]. \(use count 2, weak count 1\) = {get\(\) = 0x.*}} } }
|
||||||
|
|
||||||
std::cout << "\n";
|
std::cout << "\n";
|
||||||
return 0; // Mark SPOT
|
return 0; // Mark SPOT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue