Skip to content

Commit 73bb615

Browse files
author
git apple-llvm automerger
committed
Merge commit '932d7db75a27' from swift/release/5.9 into stable/20221013
2 parents 2ed60a5 + 932d7db commit 73bb615

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,24 @@ __builtin_logger_initialize()
329329

330330
assert(!playground && !repl && "Playground/REPL mode not expected");
331331

332+
auto path_literal = [](const char *path) -> std::string {
333+
std::string escaped;
334+
llvm::raw_string_ostream os(escaped);
335+
llvm::printEscapedString(path, os);
336+
return escaped;
337+
};
338+
332339
if (pound_file && pound_line) {
333340
fixed_text.Printf("#sourceLocation(file: \"%s\", line: %u)\n%s\n",
334-
pound_file, pound_line, orig_text);
341+
path_literal(pound_file).c_str(), pound_line, orig_text);
335342
text = fixed_text.GetString().data();
336343
} else if (generate_debug_info) {
337344
std::string expr_source_path;
338345
if (SwiftASTManipulator::SaveExpressionTextToTempFile(orig_text, options,
339346
expr_source_path)) {
340347
fixed_text.Printf("#sourceLocation(file: \"%s\", line: 1)\n%s\n",
341-
expr_source_path.c_str(), orig_text);
348+
path_literal(expr_source_path.c_str()).c_str(),
349+
orig_text);
342350
text = fixed_text.GetString().data();
343351
}
344352
}

0 commit comments

Comments
 (0)