[all-commits] [llvm/llvm-project] 1414a5: [lldb][DataFormatter] Fix libcxx std::deque format...

Michael Buch via All-commits all-commits at lists.llvm.org
Mon Apr 17 13:32:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1414a5bdfeff3dbbbaae9816ef4017c81112c3c0
      https://github.com/llvm/llvm-project/commit/1414a5bdfeff3dbbbaae9816ef4017c81112c3c0
  Author: Michael Buch <michaelbuch12 at gmail.com>
  Date:   2023-04-17 (Mon, 17 Apr 2023)

  Changed paths:
    M lldb/examples/synthetic/libcxx.py
    A lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile
    A lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
    A lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list