[clang] [clang] Adjust TextDiagnostic style ranges for interesting source region (PR #164941)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 31 03:59:23 PDT 2025
================
@@ -1391,6 +1421,12 @@ void TextDiagnostic::emitSnippetAndCaret(
OS.indent(MaxLineNoDisplayWidth + 2) << "| ";
};
+ Columns MessageLength = DiagOpts.MessageLength;
+
+ // If we don't have enough columns available, just abort now.
+ if (MessageLength != 0 && MessageLength <= Columns(MaxLineNoDisplayWidth + 4))
+ return;
----------------
Sirraide wrote:
```suggestion
Columns MessageLength = DiagOpts.MessageLength;
if (MessageLength != 0)
MessageLength = std::max(MessageLength, Columns(40));
```
I think it makes more sense to clamp `MessageLength` to some minimum value, e.g. `20` or `40`. Because if someone seriously passes e.g. `-fmessage-length=5`, I candidly have no idea what they’re expecting us to do with that.
https://github.com/llvm/llvm-project/pull/164941
More information about the cfe-commits
mailing list