Skip to content

Commit deda49c

Browse files
committed
[lldb] Fix Array<T>.SubSequence synthetic (#5523)
`Array<T>.SubSequence` is a typealias to `ArraySlice<T>`. LLDB provides a synthetic type for `ArraySlice`. When printing a value of `Array<T>.SubSequence`, the formatting system correctly peels off the typealias and selects the `ArraySlice` synthetic provider. However the implementation of the `ArraySlice` synthetic provider (see `SwiftArrayBufferHandler`) handles a number of related array types, including `Array`, `ContiguousArray`, `ArraySlice`, and more. In handling these types, `SwiftArrayBufferHandler` does string matching on the type name to determine its behavior. This string matching is done on the exact type, no typealias layers are removed. For `Array<T>.SubSequence` to be handled as `ArraySlice`, the string matching needs to be updated accordingly. This change does that. rdar://92898538 (cherry picked from commit df5cdd1)
1 parent 21b0c97 commit deda49c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lldb/source/Plugins/Language/Swift/SwiftArray.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@ SwiftArrayBufferHandler::CreateBufferHandler(ValueObject &valobj) {
375375
if (handler && handler->IsValid())
376376
return handler;
377377
return nullptr;
378-
} else if (valobj_typename.startswith("Swift.ArraySlice<")) {
379-
// Swift.ArraySlice
378+
} else if (valobj_typename.startswith("Swift.ArraySlice<") ||
379+
(valobj_typename.startswith("Swift.Array<") &&
380+
valobj_typename.endswith(">.SubSequence"))) {
381+
// ArraySlice or Array<T>.SubSequence, which is a typealias to ArraySlice.
380382
static ConstString g_buffer("_buffer");
381383

382384
ValueObjectSP buffer_sp(

lldb/test/API/functionalities/data-formatter/swift/array-slice/TestSwiftArraySliceFormatters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ def test_swift_array_slice_formatters(self):
1616
self, "break here", lldb.SBFileSpec("main.swift")
1717
)
1818

19-
# TODO: Fix `arraySubSequence` rdar://92898538
20-
for var in ("someSlice", "arraySlice"):
19+
for var in ("someSlice", "arraySlice", "arraySubSequence"):
2120
self.expect(f"v {var}", substrs=[f"{var} = 2 values", "[1] = 2", "[2] = 3"])

0 commit comments

Comments
 (0)