[PATCH] D150843: [clang][Diagnostics] Refactor printableTextForNextCharacter
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 18 23:12:34 PDT 2023
tbaeder added inline comments.
================
Comment at: clang/lib/Frontend/TextDiagnostic.cpp:121
+ unsigned CharSize = llvm::getNumBytesForUTF8(*Begin);
+ const unsigned char *End = Begin + CharSize;
----------------
tahonermann wrote:
> This could assign `End` to a location past the end of the source line when the source line ends with an ill-formed code unit sequence (e.g., a truncated 4-byte sequence). Constructing such a pointer is likely to get one in trouble.
If we use `bytes_end()` (unconditionally) we will check the entire source line every time we call this function (which always happens in a loop), which is what I was trying to avoid.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150843/new/
https://reviews.llvm.org/D150843
More information about the cfe-commits
mailing list