[Lex] Use WritableMemoryBuffer in ScratchBuffer.cpp

This avoids the need to const_cast the buffer contents to write to it.

NFCI.

llvm-svn: 322268
This commit is contained in:
Pavel Labath 2018-01-11 10:43:45 +00:00
parent d037b1446b
commit da45439fba
1 changed files with 4 additions and 4 deletions

View File

@ -74,11 +74,11 @@ void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {
// Get scratch buffer. Zero-initialize it so it can be dumped into a PCH file
// deterministically.
std::unique_ptr<llvm::MemoryBuffer> OwnBuf =
llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>");
llvm::MemoryBuffer &Buf = *OwnBuf;
std::unique_ptr<llvm::WritableMemoryBuffer> OwnBuf =
llvm::WritableMemoryBuffer::getNewMemBuffer(RequestLen,
"<scratch space>");
CurBuffer = OwnBuf->getBufferStart();
FileID FID = SourceMgr.createFileID(std::move(OwnBuf));
BufferStartLoc = SourceMgr.getLocForStartOfFile(FID);
CurBuffer = const_cast<char*>(Buf.getBufferStart());
BytesUsed = 0;
}