Skip to content

Commit 6ca56a2

Browse files
committed
Fix a logic error that would prevent display of ClangImporter error in
the expression evaluator. rdar://76217088 (cherry picked from commit a311bc5)
1 parent 34fc96f commit 6ca56a2

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,11 +1481,7 @@ unsigned SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
14811481
retry = true;
14821482
},
14831483
[&](const SwiftASTContextError &SACE) {
1484-
if (swift_ast_ctx->GetClangImporter())
1485-
DiagnoseSwiftASTContextError();
1486-
else
1487-
// Discard the shared scratch context and retry.
1488-
retry = true;
1484+
DiagnoseSwiftASTContextError();
14891485
},
14901486
[&](const StringError &SE) {
14911487
diagnostic_manager.PutString(eDiagnosticSeverityError,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR)
3+
4+
include Makefile.rules
5+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import unittest2
6+
7+
class TestSwiftExprImport(TestBase):
8+
9+
mydir = TestBase.compute_mydir(__file__)
10+
11+
def setUp(self):
12+
TestBase.setUp(self)
13+
14+
# Don't run ClangImporter tests if Clangimporter is disabled.
15+
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
16+
@swiftTest
17+
def test(self):
18+
"""Test error handling if the expression evaluator
19+
encounters a Clang import failure.
20+
"""
21+
self.build()
22+
23+
lldbutil.run_to_source_breakpoint(self, "break here",
24+
lldb.SBFileSpec('main.swift'))
25+
self.expect("expr -- import A", error=True,
26+
substrs=['could','not','build','module'])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int i = SYNTAX_ERROR;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
func f() {}
2+
3+
print("break here")
4+
f()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module A {
2+
header "a.h"
3+
}

0 commit comments

Comments
 (0)