[llvm] [SourceMgr] Clean up handling of line ending characters (PR #120605)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 09:06:59 PST 2024


jayfoad wrote:

> Change the offset cache to point to the start of each line, instead of each terminating LF character, and consistently handle CR, LF and CRLF (or LFCR) line ending sequences.

This was inspired by the TableGen lexer, which supports all four of these line endings.

> These functions are now faster and simpler.

Speeding up `getLineAndColumn` gave me a 1.2x overall speedup in my TableGen preprocessor: #120113


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


More information about the llvm-commits mailing list