[cfe-commits] r71870 - in /cfe/trunk: lib/Frontend/TextDiagnosticPrinter.cpp test/Misc/message-length.c

Douglas Gregor dgregor at apple.com
Fri May 15 11:05:24 PDT 2009


Author: dgregor
Date: Fri May 15 13:05:24 2009
New Revision: 71870

URL: http://llvm.org/viewvc/llvm-project?rev=71870&view=rev
Log:
When word-wrapping, be more defensive about a ridiculously small number of columns. Fixes <rdar://problem/6892178>

Modified:
    cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
    cfe/trunk/test/Misc/message-length.c

Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=71870&r1=71869&r2=71870&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Fri May 15 13:05:24 2009
@@ -160,10 +160,12 @@
 
   // If the end of the interesting region comes before we run out of
   // space in the terminal, start at the beginning of the line.
-  if (CaretEnd < Columns - 3)
+  if (Columns > 3 && CaretEnd < Columns - 3)
     CaretStart = 0;
 
-  unsigned TargetColumns = Columns - 8; // Give us extra room for the ellipses.
+  unsigned TargetColumns = Columns;
+  if (TargetColumns > 8)
+    TargetColumns -= 8; // Give us extra room for the ellipses.
   unsigned SourceLength = SourceLine.size();
   while ((CaretEnd - CaretStart) < TargetColumns) {
     bool ExpandedRegion = false;

Modified: cfe/trunk/test/Misc/message-length.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/message-length.c?rev=71870&r1=71869&r2=71870&view=diff

==============================================================================
--- cfe/trunk/test/Misc/message-length.c (original)
+++ cfe/trunk/test/Misc/message-length.c Fri May 15 13:05:24 2009
@@ -4,7 +4,7 @@
 // FIXME: This diagnostic is getting truncated very poorly.
 // RUN: grep -e '^  ...// some long comment text and a brace, eh {} ' %t.msg &&
 // RUN: grep -e '^                                                 \^' %t.msg &&
-
+// RUN: clang -fsyntax-only -fmessage-length=1 %s &&
 // RUN: true
 
 // Hack so we can check things better, force the file name and line.





More information about the cfe-commits mailing list