summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-15 18:05:24 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-15 18:05:24 +0000
commit12c3a5cedfed8f36898991c09d4ab85d3a60b2d2 (patch)
treec75f27abed445e05d0d8a9225b16c4554d65b749
parent67da0d97e6790cc554aa0ca9986ee8651797caaf (diff)
downloadbcm5719-llvm-12c3a5cedfed8f36898991c09d4ab85d3a60b2d2.tar.gz
bcm5719-llvm-12c3a5cedfed8f36898991c09d4ab85d3a60b2d2.zip
When word-wrapping, be more defensive about a ridiculously small number of columns. Fixes <rdar://problem/6892178>
llvm-svn: 71870
-rw-r--r--clang/lib/Frontend/TextDiagnosticPrinter.cpp6
-rw-r--r--clang/test/Misc/message-length.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
index f936807b6cf..09c29109f18 100644
--- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -160,10 +160,12 @@ static void SelectInterestingSourceRegion(std::string &SourceLine,
// 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;
diff --git a/clang/test/Misc/message-length.c b/clang/test/Misc/message-length.c
index d64b1bfc58a..ac5dab99ca5 100644
--- a/clang/test/Misc/message-length.c
+++ b/clang/test/Misc/message-length.c
@@ -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.
OpenPOWER on IntegriCloud