Skip to content

Commit f8d883a

Browse files
[lldb][swift] Fix GetParentIfClosure for didSet of properties
Like previous cases, this requires supporting a few more mangling node Kinds. This one also requires a separate test Struct/Class because a `didSet` is not allowed to co-exist with a custom setter.
1 parent 97e4c9c commit f8d883a

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ std::string SwiftLanguageRuntime::GetParentNameIfClosure(Function &func) {
15571557
static const auto function_kinds = {
15581558
Kind::ImplicitClosure, Kind::ExplicitClosure, Kind::Function,
15591559
Kind::Constructor, Kind::Static, Kind::Getter,
1560-
Kind::Setter};
1560+
Kind::Setter, Kind::DidSet};
15611561
auto *closure_node = swift_demangle::GetFirstChildOfKind(node, closure_kinds);
15621562
auto *parent_func_node =
15631563
swift_demangle::GetFirstChildOfKind(closure_node, function_kinds);

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ def test_ctor_class_closure(self):
149149
f"MY_CLASS.class_computed_property.{kind}",
150150
)
151151
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
152+
lldbutil.continue_to_source_breakpoint(
153+
self,
154+
process,
155+
f"break_class_computed_property_didset",
156+
lldb.SBFileSpec("main.swift"),
157+
)
158+
check_not_captured_error(
159+
self,
160+
thread.frames[0],
161+
"find_me",
162+
f"MY_CLASS.class_computed_property_didset.didset",
163+
)
164+
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
152165

153166
@swiftTest
154167
def test_ctor_struct_closure(self):
@@ -193,6 +206,19 @@ def test_ctor_struct_closure(self):
193206
f"MY_STRUCT.struct_computed_property.{kind}",
194207
)
195208
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
209+
lldbutil.continue_to_source_breakpoint(
210+
self,
211+
process,
212+
f"break_struct_computed_property_didset",
213+
lldb.SBFileSpec("main.swift"),
214+
)
215+
check_not_captured_error(
216+
self,
217+
thread.frames[0],
218+
"find_me",
219+
f"MY_STRUCT.struct_computed_property_didset.didset",
220+
)
221+
check_no_enhanced_diagnostic(self, thread.frames[0], "dont_find_me")
196222

197223
@swiftTest
198224
def test_ctor_enum_closure(self):

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ class MY_CLASS {
123123
let dont_find_me = "hello"
124124
}
125125
}
126+
127+
public var class_computed_property_didset: Int = 0 {
128+
didSet {
129+
let find_me = "hello"
130+
let _ = {
131+
print("break_class_computed_property_didset")
132+
return 10
133+
}()
134+
let dont_find_me = "hello"
135+
}
136+
}
126137
}
127138

128139
struct MY_STRUCT {
@@ -163,6 +174,17 @@ struct MY_STRUCT {
163174
let dont_find_me = "hello"
164175
}
165176
}
177+
178+
public var struct_computed_property_didset: Int = 0 {
179+
didSet {
180+
let find_me = "hello"
181+
let _ = {
182+
print("break_struct_computed_property_didset")
183+
return 10
184+
}()
185+
let dont_find_me = "hello"
186+
}
187+
}
166188
}
167189

168190
enum MY_ENUM {
@@ -197,9 +219,11 @@ var my_class = MY_CLASS(input: [1, 2])
197219
MY_CLASS.static_func(input_static: [42])
198220
print(my_class.class_computed_property)
199221
my_class.class_computed_property = 10
222+
my_class.class_computed_property_didset = 10;
200223
var my_struct = MY_STRUCT(input: [1, 2])
201224
MY_STRUCT.static_func(input_static: [42])
202225
print(my_struct.struct_computed_property)
203226
my_struct.struct_computed_property = 10
227+
my_struct.struct_computed_property_didset = 10
204228
let _ = MY_ENUM(input: [1,2])
205229
MY_ENUM.static_func(input_static: [42])

0 commit comments

Comments
 (0)