diff --git a/clang/lib/Lex/ScratchBuffer.cpp b/clang/lib/Lex/ScratchBuffer.cpp index e0f3966fce48..dc03e16daa8b 100644 --- a/clang/lib/Lex/ScratchBuffer.cpp +++ b/clang/lib/Lex/ScratchBuffer.cpp @@ -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 OwnBuf = - llvm::MemoryBuffer::getNewMemBuffer(RequestLen, ""); - llvm::MemoryBuffer &Buf = *OwnBuf; + std::unique_ptr OwnBuf = + llvm::WritableMemoryBuffer::getNewMemBuffer(RequestLen, + ""); + CurBuffer = OwnBuf->getBufferStart(); FileID FID = SourceMgr.createFileID(std::move(OwnBuf)); BufferStartLoc = SourceMgr.getLocForStartOfFile(FID); - CurBuffer = const_cast(Buf.getBufferStart()); BytesUsed = 0; }