r234184 - Prefer uninitialized memory for scratch space.
Benjamin Kramer
benny.kra at googlemail.com
Mon Apr 6 10:45:11 PDT 2015
Author: d0k
Date: Mon Apr 6 12:45:11 2015
New Revision: 234184
URL: http://llvm.org/viewvc/llvm-project?rev=234184&view=rev
Log:
Prefer uninitialized memory for scratch space.
No functional change intended.
Modified:
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Lex/ScratchBuffer.cpp
Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=234184&r1=234183&r2=234184&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Apr 6 12:45:11 2015
@@ -110,8 +110,8 @@ llvm::MemoryBuffer *ContentCache::getBuf
// possible.
if (!BufferOrError) {
StringRef FillStr("<<<MISSING SOURCE FILE>>>\n");
- Buffer.setPointer(MemoryBuffer::getNewMemBuffer(ContentsEntry->getSize(),
- "<invalid>").release());
+ Buffer.setPointer(MemoryBuffer::getNewUninitMemBuffer(
+ ContentsEntry->getSize(), "<invalid>").release());
char *Ptr = const_cast<char*>(Buffer.getPointer()->getBufferStart());
for (unsigned i = 0, e = ContentsEntry->getSize(); i != e; ++i)
Ptr[i] = FillStr[i % FillStr.size()];
Modified: cfe/trunk/lib/Lex/ScratchBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ScratchBuffer.cpp?rev=234184&r1=234183&r2=234184&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ScratchBuffer.cpp (original)
+++ cfe/trunk/lib/Lex/ScratchBuffer.cpp Mon Apr 6 12:45:11 2015
@@ -65,7 +65,7 @@ void ScratchBuffer::AllocScratchBuffer(u
RequestLen = ScratchBufSize;
std::unique_ptr<llvm::MemoryBuffer> OwnBuf =
- llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>");
+ llvm::MemoryBuffer::getNewUninitMemBuffer(RequestLen, "<scratch space>");
llvm::MemoryBuffer &Buf = *OwnBuf;
FileID FID = SourceMgr.createFileID(std::move(OwnBuf));
BufferStartLoc = SourceMgr.getLocForStartOfFile(FID);
More information about the cfe-commits
mailing list