[lldb][DataFormatter] Fix libcxx std::deque formatter for references and pointers
authorMichael Buch <michaelbuch12@gmail.com>
Mon, 17 Apr 2023 14:04:57 +0000 (15:04 +0100)
committerMichael Buch <michaelbuch12@gmail.com>
Mon, 17 Apr 2023 20:31:30 +0000 (21:31 +0100)
commit1414a5bdfeff3dbbbaae9816ef4017c81112c3c0
treec06f3a1f4e99d89e91d7979ddfeb7f56875c0e42
parent7d4824b1578903574b0dfd6fa68366b7180b508f
[lldb][DataFormatter] Fix libcxx std::deque formatter for references and pointers

(Addresses GH#62153)

The `SBType` APIs to retrieve details about template arguments,
such as `GetTemplateArgumentType` or `GetTemplateArgumentKind`
don't "desugar" LValueReferences/RValueReferences or pointers.
So when we try to format a `std::deque&`, the python call to
`GetTemplateArgumentType` fails to get a type, leading to
an `element_size` of `0` and a division-by-zero python exception
(which gets caught by the summary provider silently). This leads
to the contents of such `std::deque&` to be printed incorrectly.

This patch dereferences the reference/pointer before calling
into the above SBAPIs.

**Testing**

* Add API test

Differential Revision: https://reviews.llvm.org/D148531
lldb/examples/synthetic/libcxx.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile [new file with mode: 0644]
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py [new file with mode: 0644]
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp [new file with mode: 0644]