Skip to content

Commit fcbd055

Browse files
[lldb][swift] Fix GetParentIfClosure for static methods of classes
These use the Static mangled node, which we were not handling.
1 parent 4f4a7bc commit fcbd055

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ std::string SwiftLanguageRuntime::GetParentNameIfClosure(StringRef name) {
15131513
Kind::ExplicitClosure};
15141514
static const auto function_kinds = {Kind::ImplicitClosure,
15151515
Kind::ExplicitClosure, Kind::Function,
1516-
Kind::Constructor};
1516+
Kind::Constructor, Kind::Static};
15171517
auto *closure_node = swift_demangle::GetFirstChildOfKind(node, closure_kinds);
15181518
auto *parent_func_node =
15191519
swift_demangle::GetFirstChildOfKind(closure_node, function_kinds);

lldb/test/API/lang/swift/closures_var_not_captured/TestSwiftClosureVarNotCaptured.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,20 @@ def test_ctor_class_closure(self):
113113
check_not_captured_error(self, thread.frames[0], "input", "MY_STRUCT.init(input:)")
114114
check_not_captured_error(self, thread.frames[0], "find_me", "MY_STRUCT.init(input:)")
115115
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
116+
117+
lldbutil.continue_to_source_breakpoint(
118+
self, process, "break_static_member", lldb.SBFileSpec("main.swift")
119+
)
120+
check_not_captured_error(
121+
self,
122+
thread.frames[0],
123+
"input_static",
124+
"static MY_STRUCT.static_func(input_static:)",
125+
)
126+
check_not_captured_error(
127+
self,
128+
thread.frames[0],
129+
"find_me_static",
130+
"static MY_STRUCT.static_func(input_static:)",
131+
)
132+
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me_static")

lldb/test/API/lang/swift/closures_var_not_captured/main.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,18 @@ class MY_STRUCT {
9595
}
9696
let dont_find_me = "hello"
9797
}
98+
99+
static func static_func(input_static: [Int]) {
100+
let find_me_static = "hello"
101+
let _ = input_static.map {
102+
return $0 // break_static_member
103+
}
104+
let dont_find_me_static = "hello"
105+
}
98106
}
99107

100108
func_1(arg: 42)
101109
func_2(arg: 42)
102110
await func_3(arg: 42)
103111
let _ = MY_STRUCT(input: [1, 2])
112+
MY_STRUCT.static_func(input_static: [42])

0 commit comments

Comments
 (0)