[cfe-commits] r101426 - in /cfe/trunk: lib/Frontend/TextDiagnosticPrinter.cpp test/Misc/message-length.c
Douglas Gregor
dgregor at apple.com
Thu Apr 15 17:23:51 PDT 2010
Author: dgregor
Date: Thu Apr 15 19:23:51 2010
New Revision: 101426
URL: http://llvm.org/viewvc/llvm-project?rev=101426&view=rev
Log:
Fix a bug in caret-line-pruning logic that only happens when we have a
source line wider than the terminal where the associated fix-it line
is longer than the caret line. Previously, we would crash in this
case, which was rather unfortunate. Fixes <rdar://problem/7856226>.
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=101426&r1=101425&r2=101426&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Thu Apr 15 19:23:51 2010
@@ -148,9 +148,16 @@
std::string &FixItInsertionLine,
unsigned EndOfCaretToken,
unsigned Columns) {
- if (CaretLine.size() > SourceLine.size())
- SourceLine.resize(CaretLine.size(), ' ');
-
+ unsigned MaxSize = std::max(SourceLine.size(),
+ std::max(CaretLine.size(),
+ FixItInsertionLine.size()));
+ if (MaxSize > SourceLine.size())
+ SourceLine.resize(MaxSize, ' ');
+ if (MaxSize > CaretLine.size())
+ CaretLine.resize(MaxSize, ' ');
+ if (!FixItInsertionLine.empty() && MaxSize > FixItInsertionLine.size())
+ FixItInsertionLine.resize(MaxSize, ' ');
+
// Find the slice that we need to display the full caret line
// correctly.
unsigned CaretStart = 0, CaretEnd = CaretLine.size();
Modified: cfe/trunk/test/Misc/message-length.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/message-length.c?rev=101426&r1=101425&r2=101426&view=diff
==============================================================================
--- cfe/trunk/test/Misc/message-length.c (original)
+++ cfe/trunk/test/Misc/message-length.c Thu Apr 15 19:23:51 2010
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fmessage-length 72 %s 2>&1 | FileCheck -strict-whitespace %s
-// RUN: %clang_cc1 -fmessage-length 1 %s
-
+// RUN: not %clang_cc1 -fmessage-length 72 %s 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -fmessage-length 1 %s
+// RUN: not %clang_cc1 -fmessage-length 8 %s 2>&1 | FileCheck -check-prefix=CHECK-DOT %s
// Hack so we can check things better, force the file name and line.
# 1 "FILE" 1
@@ -30,3 +30,13 @@
// CHECK: FILE:23:78
// CHECK: {{^ ...// some long comment text and a brace, eh {} }}
+
+struct A { int x; };
+void h(struct A *a) {
+ // CHECK-DOT: member
+ // CHECK-DOT: reference
+ // CHECK-DOT: type
+ (void)a
+ .
+ x;
+}
More information about the cfe-commits
mailing list