Skip to content

Commit cf4b098

Browse files
committed
Ensure that macro expansion buffers terminate in a newline when written to disk.
This helps LLDB recognize the last line of the macro.
1 parent 6335f1d commit cf4b098

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Basic/SourceLoc.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ dumpBufferToFile(const llvm::MemoryBuffer *buffer) {
204204
return None;
205205

206206
// Dump the contents there.
207+
auto contents = buffer->getBuffer();
207208
llvm::raw_fd_ostream out(tempFD, true);
208-
out << buffer->getBuffer();
209+
out << contents;
210+
if (contents.empty() || contents.back() != '\n')
211+
out << "\n";
209212
out.flush();
210213

211214
llvm::sys::DontRemoveFileOnSignal(tempFileName);

0 commit comments

Comments
 (0)