Skip to content

Commit c41fec0

Browse files
[lldb] Detect not-captured variables in DIL's impl of GetValueForVariableExpressionPath
This requires changing the VisitIdentifier method. Like in the legacy implementation, we can upstream these changes once we have a C++ mechanism for detecting the parent closure of a closure from its mangled name.
1 parent 89fe40a commit c41fec0

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

lldb/source/ValueObject/DILEval.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ Interpreter::Visit(const IdentifierNode *node) {
161161
identifier = LookupGlobalIdentifier(node->GetName(), m_exe_ctx_scope,
162162
m_target, use_dynamic);
163163
if (!identifier) {
164+
// BEGIN SWIFT
165+
// Implement LanguageCPlusPlus::GetParentNameIfClosure and upstream this.
166+
// rdar://152321823
167+
if (std::string message =
168+
m_exe_ctx_scope->GetVariableNotCapturedDiagnostic(node->GetName());
169+
!message.empty())
170+
return llvm::make_error<DILDiagnosticError>(
171+
m_expr, message, node->GetLocation(), node->GetName().size());
172+
// END SWIFT
164173
std::string errMsg =
165174
llvm::formatv("use of undeclared identifier '{0}'", node->GetName());
166175
return llvm::make_error<DILDiagnosticError>(

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ def get_to_bkpt(self, bkpt_name):
5454
@swiftTest
5555
def test_simple_closure(self):
5656
self.build()
57-
# rdar://158447239
58-
self.runCmd('settings set target.experimental.use-DIL false')
5957
(target, process, thread) = self.get_to_bkpt("break_simple_closure")
6058
check_not_captured_error(self, thread.frames[0], "var_in_foo", "func_1(arg:)")
6159
check_not_captured_error(self, thread.frames[0], "arg", "func_1(arg:)")
@@ -64,8 +62,6 @@ def test_simple_closure(self):
6462
@swiftTest
6563
def test_nested_closure(self):
6664
self.build()
67-
# rdar://158447239
68-
self.runCmd('settings set target.experimental.use-DIL false')
6965
(target, process, thread) = self.get_to_bkpt("break_double_closure_1")
7066
check_not_captured_error(self, thread.frames[0], "var_in_foo", "func_2(arg:)")
7167
check_not_captured_error(self, thread.frames[0], "arg", "func_2(arg:)")
@@ -92,8 +88,6 @@ def test_nested_closure(self):
9288
@skipIf(oslist=["windows", "linux"])
9389
def test_async_closure(self):
9490
self.build()
95-
# rdar://158447239
96-
self.runCmd('settings set target.experimental.use-DIL false')
9791
(target, process, thread) = self.get_to_bkpt("break_async_closure_1")
9892
check_not_captured_error(self, thread.frames[0], "var_in_foo", "func_3(arg:)")
9993
check_not_captured_error(self, thread.frames[0], "arg", "func_3(arg:)")
@@ -115,8 +109,6 @@ def test_async_closure(self):
115109
@swiftTest
116110
def test_ctor_class_closure(self):
117111
self.build()
118-
# rdar://158447239
119-
self.runCmd('settings set target.experimental.use-DIL false')
120112
(target, process, thread) = self.get_to_bkpt("break_ctor_class")
121113
check_not_captured_error(
122114
self, thread.frames[0], "input", "MY_CLASS.init(input:)"
@@ -174,8 +166,6 @@ def test_ctor_class_closure(self):
174166
@swiftTest
175167
def test_ctor_struct_closure(self):
176168
self.build()
177-
# rdar://158447239
178-
self.runCmd('settings set target.experimental.use-DIL false')
179169
(target, process, thread) = self.get_to_bkpt("break_ctor_struct")
180170
check_not_captured_error(
181171
self, thread.frames[0], "input", "MY_STRUCT.init(input:)"
@@ -233,8 +223,6 @@ def test_ctor_struct_closure(self):
233223
@swiftTest
234224
def test_ctor_enum_closure(self):
235225
self.build()
236-
# rdar://158447239
237-
self.runCmd('settings set target.experimental.use-DIL false')
238226
(target, process, thread) = self.get_to_bkpt("break_ctor_enum")
239227
check_not_captured_error(
240228
self, thread.frames[0], "input", "MY_ENUM.init(input:)"

0 commit comments

Comments
 (0)