[Lldb-commits] [PATCH] D115331: [llvm] Add null-termination capability to SmallVectorMemoryBuffer

Jan Svoboda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 8 04:48:54 PST 2021


jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added subscribers: ormris, steven_wu, hiraditya.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: shafik.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
jansvoboda11 requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLDB, LLVM.

Most of `MemoryBuffer` interfaces expose a `RequiresNullTerminator` parameter that's being used to:

- determine how to open a file (`mmap` vs `open`),
- assert newly initialized buffer indeed has an implicit null terminator.

This patch adds the paramater to the `SmallVectorMemoryBuffer` constructors, meaning:

- null terminator can now be added to `SmallVector`s that didn't have one before,
- `SmallVectors` that had a null terminator before keep it even after the move.

In line with existing code, the new parameter is defaulted to `true`. This patch makes sure all calls to the `SmallVectorMemoryBuffer` constructor set it to `false` to preserve the current semantics.

As a drive-by fix, this patch removes unused `#include`s of `SmallVectorMemoryBuffer.h` and ensures all callers use the `auto Var = std::make_unique<SmallVectorMemoryBuffer>(...);` pattern.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115331

Files:
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/Frontend/TextDiagnosticTest.cpp
  lldb/unittests/Expression/CppModuleConfigurationTest.cpp
  llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
  llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
  llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Object/ArchiveWriter.cpp
  llvm/lib/Object/MachOUniversalWriter.cpp
  llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  llvm/unittests/Support/MemoryBufferTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115331.392716.patch
Type: text/x-patch
Size: 9907 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211208/dd474553/attachment-0001.bin>


More information about the lldb-commits mailing list