[llvm] 1c04ebb - Remove debugger pretty printers for llvm::Optional (#135235)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 14 05:11:59 PDT 2025
Author: Aaron Puchert
Date: 2025-04-14T14:11:55+02:00
New Revision: 1c04ebbbb5aff6da50aa62f08b2453e741484b85
URL: https://github.com/llvm/llvm-project/commit/1c04ebbbb5aff6da50aa62f08b2453e741484b85
DIFF: https://github.com/llvm/llvm-project/commit/1c04ebbbb5aff6da50aa62f08b2453e741484b85.diff
LOG: Remove debugger pretty printers for llvm::Optional (#135235)
Since 2916b99182752b1aece8cc4479d8d6a20b5e02da this is just an alias to
std::optional, and by now it has been removed entirely.
Added:
Modified:
llvm/utils/LLVMVisualizers/llvm.natvis
llvm/utils/gdb-scripts/prettyprinters.py
llvm/utils/lldbDataFormatters.py
Removed:
################################################################################
diff --git a/llvm/utils/LLVMVisualizers/llvm.natvis b/llvm/utils/LLVMVisualizers/llvm.natvis
index d83ae8013c51e..aa46ac100936e 100644
--- a/llvm/utils/LLVMVisualizers/llvm.natvis
+++ b/llvm/utils/LLVMVisualizers/llvm.natvis
@@ -193,14 +193,6 @@ For later versions of Visual Studio, no setup is required.
<DisplayString>{Data}</DisplayString>
</Type>
- <Type Name="llvm::Optional<*>">
- <DisplayString Condition="!Storage.hasVal">None</DisplayString>
- <DisplayString Condition="Storage.hasVal">{Storage.value}</DisplayString>
- <Expand>
- <Item Name="[underlying]" Condition="Storage.hasVal">Storage.value</Item>
- </Expand>
- </Type>
-
<Type Name="llvm::Expected<*>">
<DisplayString Condition="HasError">Error</DisplayString>
<DisplayString Condition="!HasError">{*((storage_type *)TStorage.buffer)}</DisplayString>
diff --git a/llvm/utils/gdb-scripts/prettyprinters.py b/llvm/utils/gdb-scripts/prettyprinters.py
index c78491529182b..9a856974f9f82 100644
--- a/llvm/utils/gdb-scripts/prettyprinters.py
+++ b/llvm/utils/gdb-scripts/prettyprinters.py
@@ -142,27 +142,6 @@ def to_string(self):
return "llvm::Expected{}".format(" is error" if self.val["HasError"] else "")
-class OptionalPrinter(Iterator):
- """Print an llvm::Optional object."""
-
- def __init__(self, val):
- self.val = val
-
- def __next__(self):
- val = self.val
- if val is None:
- raise StopIteration
- self.val = None
- if not val["Storage"]["hasVal"]:
- raise StopIteration
- return ("value", val["Storage"]["val"])
-
- def to_string(self):
- return "llvm::Optional{}".format(
- "" if self.val["Storage"]["hasVal"] else " is not initialized"
- )
-
-
class DenseMapPrinter:
"Print a DenseMap"
@@ -543,7 +522,6 @@ def children(self):
)
pp.add_printer("llvm::ArrayRef", "^llvm::(Mutable)?ArrayRef<.*>$", ArrayRefPrinter)
pp.add_printer("llvm::Expected", "^llvm::Expected<.*>$", ExpectedPrinter)
-pp.add_printer("llvm::Optional", "^llvm::Optional<.*>$", OptionalPrinter)
pp.add_printer("llvm::DenseMap", "^llvm::DenseMap<.*>$", DenseMapPrinter)
pp.add_printer("llvm::StringMap", "^llvm::StringMap<.*>$", StringMapPrinter)
pp.add_printer("llvm::Twine", "^llvm::Twine$", TwinePrinter)
diff --git a/llvm/utils/lldbDataFormatters.py b/llvm/utils/lldbDataFormatters.py
index 09143d2d81cbb..988827ab4aa50 100644
--- a/llvm/utils/lldbDataFormatters.py
+++ b/llvm/utils/lldbDataFormatters.py
@@ -42,16 +42,6 @@ def __lldb_init_module(debugger, internal_dict):
'-e -s "size=${svar%#}" '
'-x "^llvm::ArrayRef<.+>$"'
)
- debugger.HandleCommand(
- "type synthetic add -w llvm "
- f"-l {__name__}.OptionalSynthProvider "
- '-x "^llvm::Optional<.+>$"'
- )
- debugger.HandleCommand(
- "type summary add -w llvm "
- f"-e -F {__name__}.OptionalSummaryProvider "
- '-x "^llvm::Optional<.+>$"'
- )
debugger.HandleCommand(
"type summary add -w llvm "
f"-F {__name__}.SmallStringSummaryProvider "
@@ -177,53 +167,6 @@ def update(self):
assert self.type_size != 0
-def GetOptionalValue(valobj):
- storage = valobj.GetChildMemberWithName("Storage")
- if not storage:
- storage = valobj
-
- failure = 2
- hasVal = storage.GetChildMemberWithName("hasVal").GetValueAsUnsigned(failure)
- if hasVal == failure:
- return "<could not read llvm::Optional>"
-
- if hasVal == 0:
- return None
-
- underlying_type = storage.GetType().GetTemplateArgumentType(0)
- storage = storage.GetChildMemberWithName("value")
- return storage.Cast(underlying_type)
-
-
-def OptionalSummaryProvider(valobj, internal_dict):
- val = GetOptionalValue(valobj)
- if val is None:
- return "None"
- if val.summary:
- return val.summary
- return ""
-
-
-class OptionalSynthProvider:
- """Provides deref support to llvm::Optional<T>"""
-
- def __init__(self, valobj, internal_dict):
- self.valobj = valobj
-
- def num_children(self):
- return self.valobj.num_children
-
- def get_child_index(self, name):
- if name == "$$dereference$$":
- return self.valobj.num_children
- return self.valobj.GetIndexOfChildWithName(name)
-
- def get_child_at_index(self, index):
- if index < self.valobj.num_children:
- return self.valobj.GetChildAtIndex(index)
- return GetOptionalValue(self.valobj) or lldb.SBValue()
-
-
def SmallStringSummaryProvider(valobj, internal_dict):
# The underlying SmallVector base class is the first child.
vector = valobj.GetChildAtIndex(0)
More information about the llvm-commits
mailing list