Skip to content

Commit 875ab94

Browse files
authored
Merge pull request #3020 from CodaFi/kaleidoscope
Special-case Pattern Binding Decls Created by LLDB
2 parents 08f96c2 + 091a2b4 commit 875ab94

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ swift::Stmt *SwiftASTManipulator::ConvertExpressionToTmpReturnVarAccess(
432432
result_loc_info.tmp_var_decl);
433433

434434
const auto static_spelling_kind = swift::StaticSpellingKind::KeywordStatic;
435-
result_loc_info.binding_decl = swift::PatternBindingDecl::createImplicit(
435+
result_loc_info.binding_decl = swift::PatternBindingDecl::createForDebugger(
436436
ast_context, static_spelling_kind, var_pattern, expr, new_decl_context);
437437
result_loc_info.binding_decl->setStatic(false);
438438

@@ -445,8 +445,12 @@ swift::Stmt *SwiftASTManipulator::ConvertExpressionToTmpReturnVarAccess(
445445
body.push_back(result_loc_info.return_stmt);
446446
}
447447

448+
swift::SourceLoc brace_end = result_loc_info.orig_expr->getEndLoc();
449+
if (brace_end.isInvalid()) {
450+
brace_end = source_loc;
451+
}
448452
auto *body_stmt = swift::BraceStmt::create(
449-
ast_context, source_loc, llvm::ArrayRef<swift::ASTNode>(body), source_loc,
453+
ast_context, source_loc, llvm::ArrayRef<swift::ASTNode>(body), brace_end,
450454
true);
451455

452456
// Default construct a label info that contains nothing for the 'do'

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func main () -> Void
131131
var my_b = B()
132132

133133
my_b.method()
134+
135+
let my_c = [1, 2, 3].map { x in x }
136+
print(my_c)
134137
}
135138

136139
main()

0 commit comments

Comments
 (0)