Skip to content

Commit 1c04ebb

Browse files
authored
Remove debugger pretty printers for llvm::Optional (#135235)
Since 2916b99 this is just an alias to std::optional, and by now it has been removed entirely.
1 parent e8e9868 commit 1c04ebb

File tree

3 files changed

+0
-87
lines changed

3 files changed

+0
-87
lines changed

llvm/utils/LLVMVisualizers/llvm.natvis

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,6 @@ For later versions of Visual Studio, no setup is required.
193193
<DisplayString>{Data}</DisplayString>
194194
</Type>
195195

196-
<Type Name="llvm::Optional&lt;*&gt;">
197-
<DisplayString Condition="!Storage.hasVal">None</DisplayString>
198-
<DisplayString Condition="Storage.hasVal">{Storage.value}</DisplayString>
199-
<Expand>
200-
<Item Name="[underlying]" Condition="Storage.hasVal">Storage.value</Item>
201-
</Expand>
202-
</Type>
203-
204196
<Type Name="llvm::Expected&lt;*&gt;">
205197
<DisplayString Condition="HasError">Error</DisplayString>
206198
<DisplayString Condition="!HasError">{*((storage_type *)TStorage.buffer)}</DisplayString>

llvm/utils/gdb-scripts/prettyprinters.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,6 @@ def to_string(self):
142142
return "llvm::Expected{}".format(" is error" if self.val["HasError"] else "")
143143

144144

145-
class OptionalPrinter(Iterator):
146-
"""Print an llvm::Optional object."""
147-
148-
def __init__(self, val):
149-
self.val = val
150-
151-
def __next__(self):
152-
val = self.val
153-
if val is None:
154-
raise StopIteration
155-
self.val = None
156-
if not val["Storage"]["hasVal"]:
157-
raise StopIteration
158-
return ("value", val["Storage"]["val"])
159-
160-
def to_string(self):
161-
return "llvm::Optional{}".format(
162-
"" if self.val["Storage"]["hasVal"] else " is not initialized"
163-
)
164-
165-
166145
class DenseMapPrinter:
167146
"Print a DenseMap"
168147

@@ -543,7 +522,6 @@ def children(self):
543522
)
544523
pp.add_printer("llvm::ArrayRef", "^llvm::(Mutable)?ArrayRef<.*>$", ArrayRefPrinter)
545524
pp.add_printer("llvm::Expected", "^llvm::Expected<.*>$", ExpectedPrinter)
546-
pp.add_printer("llvm::Optional", "^llvm::Optional<.*>$", OptionalPrinter)
547525
pp.add_printer("llvm::DenseMap", "^llvm::DenseMap<.*>$", DenseMapPrinter)
548526
pp.add_printer("llvm::StringMap", "^llvm::StringMap<.*>$", StringMapPrinter)
549527
pp.add_printer("llvm::Twine", "^llvm::Twine$", TwinePrinter)

llvm/utils/lldbDataFormatters.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ def __lldb_init_module(debugger, internal_dict):
4242
'-e -s "size=${svar%#}" '
4343
'-x "^llvm::ArrayRef<.+>$"'
4444
)
45-
debugger.HandleCommand(
46-
"type synthetic add -w llvm "
47-
f"-l {__name__}.OptionalSynthProvider "
48-
'-x "^llvm::Optional<.+>$"'
49-
)
50-
debugger.HandleCommand(
51-
"type summary add -w llvm "
52-
f"-e -F {__name__}.OptionalSummaryProvider "
53-
'-x "^llvm::Optional<.+>$"'
54-
)
5545
debugger.HandleCommand(
5646
"type summary add -w llvm "
5747
f"-F {__name__}.SmallStringSummaryProvider "
@@ -177,53 +167,6 @@ def update(self):
177167
assert self.type_size != 0
178168

179169

180-
def GetOptionalValue(valobj):
181-
storage = valobj.GetChildMemberWithName("Storage")
182-
if not storage:
183-
storage = valobj
184-
185-
failure = 2
186-
hasVal = storage.GetChildMemberWithName("hasVal").GetValueAsUnsigned(failure)
187-
if hasVal == failure:
188-
return "<could not read llvm::Optional>"
189-
190-
if hasVal == 0:
191-
return None
192-
193-
underlying_type = storage.GetType().GetTemplateArgumentType(0)
194-
storage = storage.GetChildMemberWithName("value")
195-
return storage.Cast(underlying_type)
196-
197-
198-
def OptionalSummaryProvider(valobj, internal_dict):
199-
val = GetOptionalValue(valobj)
200-
if val is None:
201-
return "None"
202-
if val.summary:
203-
return val.summary
204-
return ""
205-
206-
207-
class OptionalSynthProvider:
208-
"""Provides deref support to llvm::Optional<T>"""
209-
210-
def __init__(self, valobj, internal_dict):
211-
self.valobj = valobj
212-
213-
def num_children(self):
214-
return self.valobj.num_children
215-
216-
def get_child_index(self, name):
217-
if name == "$$dereference$$":
218-
return self.valobj.num_children
219-
return self.valobj.GetIndexOfChildWithName(name)
220-
221-
def get_child_at_index(self, index):
222-
if index < self.valobj.num_children:
223-
return self.valobj.GetChildAtIndex(index)
224-
return GetOptionalValue(self.valobj) or lldb.SBValue()
225-
226-
227170
def SmallStringSummaryProvider(valobj, internal_dict):
228171
# The underlying SmallVector base class is the first child.
229172
vector = valobj.GetChildAtIndex(0)

0 commit comments

Comments
 (0)