Skip to content

Commit a3690f5

Browse files
Merge pull request #8903 from adrian-prantl/125613361
[SwiftExpressionParser] Suppress spurious variable lookup errors
2 parents 2dd7b65 + 3b5ae9e commit a3690f5

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,9 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
17751775
"Missing type debug information for variable \"%s\": %s",
17761776
var.GetName().str().str().c_str(),
17771777
llvm::toString(std::move(error)).c_str());
1778+
return ParseResult::unrecoverable_error;
17781779
}
1779-
1780+
// Otherwise print the diagnostics from the Swift compiler.
17801781
DiagnoseSwiftASTContextError();
17811782
return ParseResult::unrecoverable_error;
17821783
}

lldb/test/API/lang/swift/expression/error_reporting/TestSwiftExpressionErrorReporting.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TestSwiftExpressionErrorReportingy(TestBase):
88
NO_DEBUG_INFO_TESTCASE = True
99

1010
@swiftTest
11-
def test(self):
11+
def test_missing_var(self):
1212
"""Test error reporting in expressions reports
1313
only diagnostics in user code"""
1414
self.build()
@@ -31,3 +31,24 @@ def check(value):
3131
value = self.frame().EvaluateExpression(
3232
"ceciNestPasUnVar", options)
3333
check(value)
34+
35+
@swiftTest
36+
def test_missing_type(self):
37+
"""Test error reporting in expressions reports
38+
only diagnostics in user code"""
39+
self.build(dictionary={'HIDE_SWIFTMODULE': 'YES'})
40+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
41+
self, 'break here', lldb.SBFileSpec('main.swift'))
42+
43+
options = lldb.SBExpressionOptions()
44+
value = self.frame().EvaluateExpression("strct", options)
45+
def check(value):
46+
lines = str(value.GetError()).split('\n')
47+
self.assertTrue(lines[0].startswith('error:'))
48+
self.assertIn('Missing type', lines[0])
49+
self.assertIn('strct', lines[0])
50+
for line in lines[1:]:
51+
self.assertFalse(line.startswith('error:'))
52+
self.assertFalse(line.startswith('warning:'))
53+
54+
check(value)

lldb/test/API/lang/swift/expression/error_reporting/main.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ class State {
44
print("in class") // break here
55
}
66

7-
var number:Int
7+
var number : Int
88
}
99

10-
func f() {
10+
struct S {}
11+
12+
func f(_ strct : S) {
1113
print("in function") // break here
1214
}
1315

14-
f()
16+
f(S())
1517
State(x: 20)

0 commit comments

Comments
 (0)