[Lldb-commits] [lldb] [lldb] Improve ansi::OutputWordWrappedLines (PR #181165)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 12 07:23:52 PST 2026


================
@@ -329,9 +332,10 @@ inline void OutputWordWrappedLines(Stream &strm,
       start++;
 
     end = start + max_text_width;
-    if (end > final_end) {
+    if (end > final_end)
       end = final_end;
-    } else {
+
+    if (end != final_end) {
       // If we're not at the end of the text, make sure we break the line on
       // white space.
       while (end > start && text[end] != ' ' && text[end] != '\t' &&
----------------
DavidSpickett wrote:

In the previous version, end could end up being set to final_end, which would get into the else clause and try to do text[final_end]. This worked with a std::string but not stringref.

I was almost expecting one of the Mac ASAN bots to complain about the tests but it didn't. Maybe 1 byte off is fine for a std::string because of the newline? Anyway, we can use stringref now.

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


More information about the lldb-commits mailing list