[Lldb-commits] [PATCH] D122041: [llvm][utils] Fix llvm::Optional summary provider

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 18 14:29:08 PDT 2022


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

Returning `None` from a Python type summary results in a summary string of "None". To indicate no summary string, the implementation should return the empty string.

This change fixes a bug where the summary provider for `llvm::Optional` would incorrectly show `None`. This would happen when the underlying type itself had no summary provider. Now, when the underlying type has a summary string, that string is used, but when there is no summary, then the `Optional` will also have no summary (`return ''`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122041

Files:
  llvm/utils/lldbDataFormatters.py


Index: llvm/utils/lldbDataFormatters.py
===================================================================
--- llvm/utils/lldbDataFormatters.py
+++ llvm/utils/lldbDataFormatters.py
@@ -137,7 +137,11 @@
 
 def OptionalSummaryProvider(valobj, internal_dict):
     val = GetOptionalValue(valobj)
-    return val.summary if val else 'None'
+    if val is None:
+        return 'None'
+    if val.summary:
+        return val.summary
+    return ''
 
 class OptionalSynthProvider:
     """Provides deref support to llvm::Optional<T>"""


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122041.416608.patch
Type: text/x-patch
Size: 532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220318/e945be53/attachment.bin>


More information about the lldb-commits mailing list