<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Support/MemoryBuffer.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>use Twine instead of char* for function args (#165569)</title>
<updated>2025-10-29T15:02:28+00:00</updated>
<author>
<name>Sean Perry</name>
<email>perry@ca.ibm.com</email>
</author>
<published>2025-10-29T15:02:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3d2efe71c0db291b60add10332a058885a13398b'/>
<id>3d2efe71c0db291b60add10332a058885a13398b</id>
<content type='text'>
Changed the function arguments to take `const Twine&amp;` instead of `const
char*`. This will avoid converting StringRef's to C strings too soon (or
ever).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Changed the function arguments to take `const Twine&amp;` instead of `const
char*`. This will avoid converting StringRef's to C strings too soon (or
ever).</pre>
</div>
</content>
</entry>
<entry>
<title>Work around documented Linux mmap bug. (#152595)</title>
<updated>2025-08-13T19:39:25+00:00</updated>
<author>
<name>Richard Smith</name>
<email>richard@metafoo.co.uk</email>
</author>
<published>2025-08-13T19:39:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=85cd3d98686c47d015dbcc17f1f7d0714b00e172'/>
<id>85cd3d98686c47d015dbcc17f1f7d0714b00e172</id>
<content type='text'>
On Linux, mmap doesn't always zero-fill slack bytes ([man page]),
despite being required to do so by POSIX. If the final page of a file is
in the page cache and the bytes past the end of the file get overwritten
by some process, those bytes then remain non-zero until the page falls
out of the cache or another process overwrites them.

Stop trusting that mmap behaves properly and instead check
whether the buffer was indeed properly terminated. If not, fall back to
using `read` to read the file contents.

This fixes an obscure clang crash bug that can occur if another program
(such as an editor) mmap's a source file and writes past the end of the
mmap'd region shortly before clang or clangd attempts to parse the file.

 [man page]: https://man7.org/linux/man-pages/man2/mmap.2.html#BUGS</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On Linux, mmap doesn't always zero-fill slack bytes ([man page]),
despite being required to do so by POSIX. If the final page of a file is
in the page cache and the bytes past the end of the file get overwritten
by some process, those bytes then remain non-zero until the page falls
out of the cache or another process overwrites them.

Stop trusting that mmap behaves properly and instead check
whether the buffer was indeed properly terminated. If not, fall back to
using `read` to read the file contents.

This fixes an obscure clang crash bug that can occur if another program
(such as an editor) mmap's a source file and writes past the end of the
mmap'd region shortly before clang or clangd attempts to parse the file.

 [man page]: https://man7.org/linux/man-pages/man2/mmap.2.html#BUGS</pre>
</div>
</content>
</entry>
<entry>
<title>[SystemZ][z/OS] Refactor AutoConvert.h to remove large MVS guard (#143174)</title>
<updated>2025-06-11T19:26:49+00:00</updated>
<author>
<name>Abhina Sree</name>
<email>Abhina.Sreeskantharajan@ibm.com</email>
</author>
<published>2025-06-11T19:26:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=22fd11fe66a0d64f5ef359e21ae67a7d40936eaf'/>
<id>22fd11fe66a0d64f5ef359e21ae67a7d40936eaf</id>
<content type='text'>
This AutoConvert.h header frequently gets mislabeled as an unused
include because it is guarded by MVS internally and every usage is also
guarded. This refactors the change to remove this guard and instead make
these functions a noop on other non-z/OS platforms.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This AutoConvert.h header frequently gets mislabeled as an unused
include because it is guarded by MVS internally and every usage is also
guarded. This refactors the change to remove this guard and instead make
these functions a noop on other non-z/OS platforms.</pre>
</div>
</content>
</entry>
<entry>
<title>[SystemZ][z/OS] Update autoconversion functions to improve support for UTF-8 (#98652)</title>
<updated>2024-12-11T12:46:51+00:00</updated>
<author>
<name>Abhina Sree</name>
<email>Abhina.Sreeskantharajan@ibm.com</email>
</author>
<published>2024-12-11T12:46:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=04379c98638ac3901257b5fa319f9ece828af767'/>
<id>04379c98638ac3901257b5fa319f9ece828af767</id>
<content type='text'>
This fixes the following error when reading source and header files on
z/OS: error: source file is not valid UTF-8</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes the following error when reading source and header files on
z/OS: error: source file is not valid UTF-8</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Remove unused includes (NFC) (#116752)</title>
<updated>2024-11-20T14:51:43+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2024-11-20T14:51:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d44ea7186befe38eb2b3804b15cd1ee1777458ed'/>
<id>d44ea7186befe38eb2b3804b15cd1ee1777458ed</id>
<content type='text'>
Identified with misc-include-cleaner.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Identified with misc-include-cleaner.</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC][SystemZ][z/OS] Rename autoconversion-related functions to be less generic (#107399)</title>
<updated>2024-09-05T17:25:06+00:00</updated>
<author>
<name>Abhina Sree</name>
<email>Abhina.Sreeskantharajan@ibm.com</email>
</author>
<published>2024-09-05T17:25:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=311ac6381649fa0f7cc495db8fa697d6a9b43988'/>
<id>311ac6381649fa0f7cc495db8fa697d6a9b43988</id>
<content type='text'>
This patch renames the functions in AutoConvert.h/cpp to have a less
generic name because they are z/OS specific.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch renames the functions in AutoConvert.h/cpp to have a less
generic name because they are z/OS specific.</pre>
</div>
</content>
</entry>
<entry>
<title>Correct mismatched allocation/deallocation calls</title>
<updated>2024-05-15T16:36:19+00:00</updated>
<author>
<name>Aaron Ballman</name>
<email>aaron@aaronballman.com</email>
</author>
<published>2024-05-15T16:33:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=3f954f575156bce8ac81d6b4d94de443786befed'/>
<id>3f954f575156bce8ac81d6b4d94de443786befed</id>
<content type='text'>
This amends dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6 because ASAN
caught an issue where the allocation and deallocation were not properly
paired: https://lab.llvm.org/buildbot/#/builders/239/builds/7001

Use malloc and free throughout this file to ensure that all kinds of
memory buffers use the proper pairing.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This amends dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6 because ASAN
caught an issue where the allocation and deallocation were not properly
paired: https://lab.llvm.org/buildbot/#/builders/239/builds/7001

Use malloc and free throughout this file to ensure that all kinds of
memory buffers use the proper pairing.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] Use malloc instead of non-throwing new (#92157)</title>
<updated>2024-05-15T14:55:34+00:00</updated>
<author>
<name>Aaron Ballman</name>
<email>aaron@aaronballman.com</email>
</author>
<published>2024-05-15T14:55:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6'/>
<id>dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6</id>
<content type='text'>
When allocating a memory buffer, we use a non-throwing new so that we
can explicitly handle memory buffers that are too large to fit into
memory. However, when exceptions are disabled, LLVM installs a custom
new handler

(https://github.com/llvm/llvm-project/blob/90109d444839683b09f0aafdc50b749cb4b3203b/llvm/lib/Support/InitLLVM.cpp#L61)
that explicitly crashes when we run out of memory

(https://github.com/llvm/llvm-project/blob/de14b749fee41d4ded711e771e43043ae3100cb3/llvm/lib/Support/ErrorHandling.cpp#L188)
and that means this particular out-of-memory situation cannot be
gracefully handled.

This was discovered while working on #embed
(https://github.com/llvm/llvm-project/pull/68620) on Windows and
resulted in a crash rather than the preprocessor issuing a diagnostic as
expected.

This patch switches away from the non-throwing new to a call to malloc
(and free), which will return a null pointer without calling a custom
new handler. It is the only instance in Clang or LLVM that I could find
which used a non-throwing new, so I did not think we would need anything
more involved than this change.

Testing this would be highly platform dependent and so it does not come
with test coverage. And because it doesn't change behavior that users
are likely to be able to observe, it does not come with a release note.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When allocating a memory buffer, we use a non-throwing new so that we
can explicitly handle memory buffers that are too large to fit into
memory. However, when exceptions are disabled, LLVM installs a custom
new handler

(https://github.com/llvm/llvm-project/blob/90109d444839683b09f0aafdc50b749cb4b3203b/llvm/lib/Support/InitLLVM.cpp#L61)
that explicitly crashes when we run out of memory

(https://github.com/llvm/llvm-project/blob/de14b749fee41d4ded711e771e43043ae3100cb3/llvm/lib/Support/ErrorHandling.cpp#L188)
and that means this particular out-of-memory situation cannot be
gracefully handled.

This was discovered while working on #embed
(https://github.com/llvm/llvm-project/pull/68620) on Windows and
resulted in a crash rather than the preprocessor issuing a diagnostic as
expected.

This patch switches away from the non-throwing new to a call to malloc
(and free), which will return a null pointer without calling a custom
new handler. It is the only instance in Clang or LLVM that I could find
which used a non-throwing new, so I did not think we would need anything
more involved than this change.

Testing this would be highly platform dependent and so it does not come
with test coverage. And because it doesn't change behavior that users
are likely to be able to observe, it does not come with a release note.</pre>
</div>
</content>
</entry>
<entry>
<title>[Support][MemBuffer] Prevent UB on empty StringRefs</title>
<updated>2023-03-14T11:58:37+00:00</updated>
<author>
<name>Kadir Cetinkaya</name>
<email>kadircet@google.com</email>
</author>
<published>2023-02-24T08:36:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=710983ab540fa372e846d47e9fa80b7d8b96afb1'/>
<id>710983ab540fa372e846d47e9fa80b7d8b96afb1</id>
<content type='text'>
Empty StringRefs are usually identified by their length being zero, and
sometimes they'll have Data==nullptr (e.g. default constructed, or derived from
an operation like split/copy and result turned out to be empty).

If such StringRef objects are passed to llvm::MemoryBuffer::getMemBufferCopy,
it'll result in UB as neither src nor dst can be null, even if size is zero.

This patch prevents that UB by not issuing a copy whenever StringRef is empty.

Differential Revision: https://reviews.llvm.org/D144706
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Empty StringRefs are usually identified by their length being zero, and
sometimes they'll have Data==nullptr (e.g. default constructed, or derived from
an operation like split/copy and result turned out to be empty).

If such StringRef objects are passed to llvm::MemoryBuffer::getMemBufferCopy,
it'll result in UB as neither src nor dst can be null, even if size is zero.

This patch prevents that UB by not issuing a copy whenever StringRef is empty.

Differential Revision: https://reviews.llvm.org/D144706
</pre>
</div>
</content>
</entry>
<entry>
<title>[Support] llvm::Optional =&gt; std::optional</title>
<updated>2022-12-16T08:49:10+00:00</updated>
<author>
<name>Fangrui Song</name>
<email>i@maskray.me</email>
</author>
<published>2022-12-16T08:49:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b1df3a2c0b6a42570042934cb79ca0e4359f863b'/>
<id>b1df3a2c0b6a42570042934cb79ca0e4359f863b</id>
<content type='text'>
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
</pre>
</div>
</content>
</entry>
</feed>
