8000 Merge pull request #10912 from felipepiovezan/felipe/fix_diagnostic_1 · swiftlang/llvm-project@247dfb9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 247dfb9

Browse files
Merge pull request #10912 from felipepiovezan/felipe/fix_diagnostic_1
[lldb][swift] Fix GetParentIfClosure for static methods of classes
2 parents 106fe98 + dba046f commit 247dfb9

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
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: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,24 @@ def check_no_enhanced_diagnostic(test, frame, var_name):
4545

4646
class TestSwiftClosureVarNotCaptured(TestBase):
4747
def get_to_bkpt(self, bkpt_name):
48-
return lldbutil.run_to_source_breakpoint(
48+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
4949
self, bkpt_name, lldb.SBFileSpec("main.swift")
5050
)
51+
target.BreakpointDelete(bkpt.GetID())
52+
return (target, process, thread)
5153

5254
@swiftTest
5355
def test_simple_closure(self):
5456
self.build()
55-
(target, process, thread, bkpt) = self.get_to_bkpt("break_simple_closure")
57+
(target, process, thread) = self.get_to_bkpt("break_simple_closure")
5658
check_not_captured_error(self, thread.frames[0], "var_in_foo", "func_1(arg:)")
5759
check_not_captured_error(self, thread.frames[0], "arg", "func_1(arg:)")
5860
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
5961

6062
@swiftTest
6163
def test_nested_closure(self):
6264
self.build()
63-
(target, process, thread, bkpt) = self.get_to_bkpt("break_double_closure_1")
65+
(target, process, thread) = self.get_to_bkpt("break_double_closure_1")
6466
check_not_captured_error(self, thread.frames[0], "var_in_foo", "func_2(arg:)")
6567
check_not_captured_error(self, thread.frames[0], "arg", "func_2(arg:)")
6668
check_not_captured_error(
@@ -86,7 +88,7 @@ def test_nested_closure(self):
8688
@skipIf(oslist=["windows", "linux"])
8789
def test_async_closure(self):
8890
self.build()
89-
(target, process, thread, bkpt) = self.get_to_bkpt("break_async_closure_1")
91+
(target, process, thread) = self.get_to_bkpt("break_async_closure_1")
9092
check_not_captured_error(self, thread.frames[0], "var_in_foo", "func_3(arg:)")
9193
check_not_captured_error(self, thread.frames[0], "arg", "func_3(arg:)")
9294
check_not_captured_error(
@@ -107,7 +109,28 @@ def test_async_closure(self):
107109
@swiftTest
108110
def test_ctor_class_closure(self):
109111
self.build()
110-
(target, process, thread, bkpt) = self.get_to_bkpt("break_ctor_class")
111-
check_not_captured_error(self, thread.frames[0], "input", "MY_STRUCT.init(input:)")
112-
check_not_captured_error(self, thread.frames[0], "find_me", "MY_STRUCT.init(input:)")
112+
(target, process, thread) = self.get_to_bkpt("break_ctor_class")
113+
check_not_captured_error(
114+
self, thread.frames[0], "input", "MY_STRUCT.init(input:)"
115+
)
116+
check_not_captured_error(
117+
self, thread.frames[0], "find_me", "MY_STRUCT.init(input:)"
118+
)
113119
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
120+
121+
lldbutil.continue_to_source_breakpoint(
122+
self, process, "break_static_member", lldb.SBFileSpec("main.swift")
123+
)
124+
check_not_captured_error(
125+
self,
126+
thread.frames[0],
127+
"input_static",
128+
"static MY_STRUCT.static_func(input_static:)",
129+
)
130+
check_not_captured_error(
131+
self,
132+
thread.frames[0],
133+
"find_me_static",
134+
"static MY_STRUCT.static_func(input_static:)",
135+
)
136+
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)
0