[llvm] [MC] AsmLexer assert buffer is null-terminated at CurBuf.end() (PR #154972)

Szymon Piotr Milczek via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 16 01:19:25 PDT 2025


smilczek wrote:

My confusion arose from the fact that it is very often the case with buffers (arrays, vectors), that the `.end()` method returns an 'Iterator past the last element'.

String is an exception, and in its case, the `.end()` method instead returns a pointer to the null-terminator.
Looks like AsmLexer also expects this property from StringRef by extension, but StringRef's buffer is not necessarily required to be null-terminated.

When receiving a buffer to be parsed, it seems reasonable not to require a null terminator and if the null terminator is present, to treat it as part of the buffer and include it in size passed to StringRef's constructor.

https://github.com/llvm/llvm-project/pull/154972


More information about the llvm-commits mailing list