diff options
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 13 | ||||
-rw-r--r-- | test/Misc/message-length.c | 16 |
2 files changed, 23 insertions, 6 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 6c8137e3d2..f2b16a4b38 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -148,9 +148,16 @@ static void SelectInterestingSourceRegion(std::string &SourceLine, 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(); diff --git a/test/Misc/message-length.c b/test/Misc/message-length.c index 3c746052fd..3e69b6a206 100644 --- a/test/Misc/message-length.c +++ b/test/Misc/message-length.c @@ -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 @@ void a_very_long_line(int *ip, float *FloatPointer) { // 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; +} |