Skip to content

Commit ac66248

Browse files
Merge pull request #10903 from felipepiovezan/felipe/fix_diagnostic_0
[lldb][swift] Fix GetParentIfClosure for Init methods of classes
2 parents 45781f1 + 6eef42d commit ac66248

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,8 @@ std::string SwiftLanguageRuntime::GetParentNameIfClosure(StringRef name) {
15121512
static const auto closure_kinds = {Kind::ImplicitClosure,
15131513
Kind::ExplicitClosure};
15141514
static const auto function_kinds = {Kind::ImplicitClosure,
1515-
Kind::ExplicitClosure, Kind::Function};
1515+
Kind::ExplicitClosure, Kind::Function,
1516+
Kind::Constructor};
15161517
auto *closure_node = swift_demangle::GetFirstChildOfKind(node, closure_kinds);
15171518
auto *parent_func_node =
15181519
swift_demangle::GetFirstChildOfKind(closure_node, function_kinds);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,11 @@ def test_async_closure(self):
103103
self, thread.frames[0], "var_in_outer_closure", "closure #1 in func_3(arg:)"
104104
)
105105
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
106+
107+
@swiftTest
108+
def test_ctor_class_closure(self):
109+
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:)")
113+
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ func func_3(arg: Int) async {
8787
print(dont_find_me)
8888
}
8989

90+
class MY_STRUCT {
91+
init(input: [Int]) {
92+
let find_me = "hello"
93+
let _ = input.map {
94+
return $0 // break_ctor_class
95+
}
96+
let dont_find_me = "hello"
97+
}
98+
}
99+
90100
func_1(arg: 42)
91101
func_2(arg: 42)
92102
await func_3(arg: 42)
103+
let _ = MY_STRUCT(input: [1, 2])

0 commit comments

Comments
 (0)