-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Closed
Copy link
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
Because OS.tell() doesn't know about colors so the control characters count into the length as well, which means in
llvm-project/clang/lib/Frontend/TextDiagnostic.cpp
Lines 665 to 680 in 57ccb46
| uint64_t StartOfLocationInfo = OS.tell(); | |
| // Emit the location of this particular diagnostic. | |
| if (Loc.isValid()) | |
| emitDiagnosticLoc(Loc, PLoc, Level, Ranges); | |
| if (DiagOpts.ShowColors) | |
| OS.resetColor(); | |
| if (DiagOpts.ShowLevel) | |
| printDiagnosticLevel(OS, Level, DiagOpts.ShowColors); | |
| printDiagnosticMessage(OS, | |
| /*IsSupplemental*/ Level == DiagnosticsEngine::Note, | |
| Message, OS.tell() - StartOfLocationInfo, | |
| DiagOpts.MessageLength, DiagOpts.ShowColors); | |
| } |
we calculate the value for CurrentColumn incorrectly. On my terminal $COLUMNS is currently 120 (and llvm figures that out correctly), but the diagnostic message is wrapped even though it would fit in to the previous line just fine (as proven by passing -fmessage-length=130 or -fno-color-diagnostics):

Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer