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

Daniel Dunbar daniel at zuster.org
Sun May 3 16:04:42 PDT 2009


Author: ddunbar
Date: Sun May  3 18:04:40 2009
New Revision: 70807

URL: http://llvm.org/viewvc/llvm-project?rev=70807&view=rev
Log:
Fix an infinite loop in diagnostic printing.
 - The diagnostic is still poor, however. Doug, can you investigate?

 - Improved the test case to not depend on the file name, now it can
   be extended to actually check the formatting of the diagnostics
   (I'm hoping grep -A is portable here).

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=70807&r1=70806&r2=70807&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sun May  3 18:04:40 2009
@@ -168,8 +168,7 @@
     bool ExpandedRegion = false;
     // Move the start of the interesting region left until we've
     // pulled in something else interesting.
-    if (CaretStart && !StartIsFixed && 
-        CaretEnd - CaretStart < TargetColumns) {
+    if (CaretStart && !StartIsFixed) {
       unsigned NewStart = CaretStart;
         
       bool BadStart = false;
@@ -223,8 +222,7 @@
 
     // Move the end of the interesting region right until we've
     // pulled in something else interesting.
-    if (CaretEnd != SourceLength && 
-        CaretEnd - CaretStart < TargetColumns) {
+    if (CaretEnd != SourceLength) {
       unsigned NewEnd = CaretEnd;
 
       // Skip over any whitespace we see here; we're looking for
@@ -240,10 +238,10 @@
         CaretEnd = NewEnd;
         ExpandedRegion = true;
       }
-
-      if (!ExpandedRegion)
-        break;
     }
+
+    if (!ExpandedRegion)
+      break;
   }
 
   // [CaretStart, CaretEnd) is the slice we want. Update the various

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

==============================================================================
--- cfe/trunk/test/Misc/message-length.c (original)
+++ cfe/trunk/test/Misc/message-length.c Sun May  3 18:04:40 2009
@@ -1,4 +1,15 @@
-// RUN: clang -fsyntax-only -fmessage-length=72 %s
+// RUN: clang -fsyntax-only -fmessage-length=72 %s 2> %t &&
+
+// RUN: grep -A4 "FILE:23" %t > %t.msg &&
+// FIXME: This diagnostic is getting truncated very poorly.
+// RUN: grep -e '^  ... ' %t.msg &&
+// RUN: grep -e '^     \^' %t.msg &&
+
+// RUN: true
+
+// Hack so we can check things better, force the file name and line.
+
+# 1 "FILE" 1
 
 /* It's tough to verify the results of this test mechanically, since
    the length of the filename (and, therefore, how the word-wrapping
@@ -20,3 +31,5 @@
 
   int array0[] = { [3] 3, 5, 7, 4, 2, 7, 6, 3, 4, 5, 6, 7, 8, 9, 12, 345, 14, 345, 789, 234, 678, 345, 123, 765, 234 };
 }
+
+#pragma STDC CX_LIMITED_RANGE    // some long comment text and a brace, eh {}





More information about the cfe-commits mailing list