Skip to content

Commit 7839c19

Browse files
Merge pull request #10801 from adrian-prantl/152611562
[lldb] Add a missing check for an empty array
2 parents aaa0733 + 44bd1e9 commit 7839c19

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,8 @@ SwiftRuntimeTypeVisitor::VisitImpl(std::optional<unsigned> visit_only,
12931293
++i;
12941294
}
12951295
}
1296+
if (supers.empty())
1297+
return llvm::createStringError("could not get instance type info");
12961298

12971299
// Handle the "real" fields.
12981300
auto *object = supers[0].get_record_type_info();

lldb/test/API/lang/swift/foundation_value_types/notification/TestSwiftFoundationTypeNotification.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ def test(self):
3232
substrs=['name = ', '"MyNotification"',
3333
'object = nil',
3434
'userInfo = 0 key/value pairs'])
35+
name = self.frame().FindVariable("name")
36+
# This is a "don't crash" test.
37+
child = name.GetChildAtIndex(0)
38+
self.assertEquals(name.GetSummary(), '"MyNotification"')

lldb/test/API/lang/swift/foundation_value_types/notification/main.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Foundation
22

33
func main() {
4-
var notification = Notification(name: Notification.Name(rawValue: "MyNotification"), object: nil, userInfo: [:])
4+
var name = Notification.Name(rawValue: "MyNotification")
5+
var notification = Notification(name: name, object: nil, userInfo: [:])
56
print("break here!")
67
}
78

0 commit comments

Comments
 (0)