This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Add null-termination capability to SmallVectorMemoryBuffer
ClosedPublic

Authored by jansvoboda11 on Dec 8 2021, 4:48 AM.

Details

Summary

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 SmallVectors 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.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Dec 8 2021, 4:48 AM
jansvoboda11 requested review of this revision.Dec 8 2021, 4:48 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptDec 8 2021, 4:48 AM
dexonsmith accepted this revision.Dec 8 2021, 10:11 AM

LGTM, except I'd prefer the #includes be changed separately since that cleanup seems unrelated to this change.

lldb/unittests/Expression/CppModuleConfigurationTest.cpp
14 ↗(On Diff #392716)

Please clean up the includes in a prep commit (no need for review IMO) rather than a drive-by.

This revision is now accepted and ready to land.Dec 8 2021, 10:11 AM
jansvoboda11 edited the summary of this revision. (Show Details)Dec 9 2021, 1:46 AM
This revision was landed with ongoing or failed builds.Dec 9 2021, 2:32 AM
This revision was automatically updated to reflect the committed changes.