[PATCH] D157961: [llvm][utils] Support SmallVector with pointer-type template parameter

Michael Buch via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 03:45:52 PDT 2023


Michael137 created this revision.
Michael137 added reviewers: kastiglione, aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Previously types such as `SmallVector<clang::Attr *, 4> *` would
trigger the assertion inside the `SmallVector` formatter:

  assert self.type_size != 0

This happens because `the_type.GetTemplateArgumentType(0)` returns
`None` (since `the_type` is a pointer to the `SmallVector`).

This patch dereferences `the_type` if it's a pointer type. We do this
for references already.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157961

Files:
  llvm/utils/lldbDataFormatters.py


Index: llvm/utils/lldbDataFormatters.py
===================================================================
--- llvm/utils/lldbDataFormatters.py
+++ llvm/utils/lldbDataFormatters.py
@@ -129,11 +129,13 @@
         if the_type.IsReferenceType():
             the_type = the_type.GetDereferencedType()
 
+        if the_type.IsPointerType():
+            the_type = the_type.GetPointeeType()
+
         self.data_type = the_type.GetTemplateArgumentType(0)
         self.type_size = self.data_type.GetByteSize()
         assert self.type_size != 0
 
-
 class ArrayRefSynthProvider:
     """Provider for llvm::ArrayRef"""
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157961.550243.patch
Type: text/x-patch
Size: 619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230815/bfad9549/attachment-0001.bin>


More information about the llvm-commits mailing list