]> granicus.if.org Git - clang/commitdiff
Prefer uninitialized memory for scratch space.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 6 Apr 2015 17:45:11 +0000 (17:45 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 6 Apr 2015 17:45:11 +0000 (17:45 +0000)
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234184 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp
lib/Lex/ScratchBuffer.cpp

index 118e3f32008b0b08f35624a32f260a2a9875b793..c0b045331dd641fdde3c73bdf15db3d556bdbe3b 100644 (file)
@@ -110,8 +110,8 @@ llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag,
   // 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()];
index 3bac8891c646bd9d899d21bf0956b05ea6e7d909..42cfca73d3d3717a452485bf2d69245a362aba9f 100644 (file)
@@ -65,7 +65,7 @@ void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {
     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);