[PATCH] D46205: Set MemoryBuffer's RequiresNullTerminator to false by default.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 27 12:27:54 PDT 2018


ruiu created this revision.
ruiu added reviewers: inglorion, espindola.
Herald added subscribers: hiraditya, klimek.

MemoryBuffer::getFile()-family functions take RequiresNullTerminator
boolean argument. If it is true, MemoryBuffer ensures that the buffer
ends with '\0'. By default, it is true.

But that default was not reasonable. If you are reading binary files,
or even if you are reading text files, you usually don't need a nul
terminator character. However, because it's default, we do that in many
places.

This patch flips the default so that we don't append '\0' by default.

I tested this patch by adding code to add a dummy non-'\0' byte at end
of a buffer if RequiresNullTerminator is false and run all tests.


https://reviews.llvm.org/D46205

Files:
  clang/lib/Tooling/CompilationDatabase.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/clang-refactor/TestSupport.cpp
  lld/COFF/Driver.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/AsmParser/Parser.cpp
  llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
  llvm/lib/Support/SourceMgr.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/CodeCoverage.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/unittests/AsmParser/AsmParserTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46205.144384.patch
Type: text/x-patch
Size: 15437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180427/6e914f38/attachment.bin>


More information about the llvm-commits mailing list