aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-09-26 16:43:25 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-09-26 16:43:25 +0000
commit64b0cee15206d55913240dca676ed3f340c60926 (patch)
tree60b737b19038a6cfdcc7b8d50374f9433ef1d122
parent43202aee91646c9b5cd6d5cbea690b479075b67b (diff)
Add back support for a manually formatted section of the diagnostic
message. Specifically, we now only line-wrap the first line of te diagnostic message and assume the remainder is manually formatted. While adding it back, simplify the logic for doing this. Finally, add a test that ensures we actually preserve this feature. =D *Now* its not dead code. Thanks to Doug for the test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140538 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp5
-rw-r--r--test/Misc/diag-line-wrapping.cpp13
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 1f6ea30c7d..64a5c1bc9c 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -1097,7 +1097,7 @@ static bool printWordWrapped(raw_ostream &OS, StringRef Str,
unsigned Columns,
unsigned Column = 0,
unsigned Indentation = WordWrapIndentation) {
- const unsigned Length = Str.size();
+ const unsigned Length = std::min(Str.find('\n'), Str.size());
// The string used to indent each line.
llvm::SmallString<16> IndentStr;
@@ -1135,6 +1135,9 @@ static bool printWordWrapped(raw_ostream &OS, StringRef Str,
Wrapped = true;
}
+ // Append any remaning text from the message with its existing formatting.
+ OS << Str.substr(Length);
+
return Wrapped;
}
diff --git a/test/Misc/diag-line-wrapping.cpp b/test/Misc/diag-line-wrapping.cpp
new file mode 100644
index 0000000000..830aa13408
--- /dev/null
+++ b/test/Misc/diag-line-wrapping.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -fmessage-length 60 %s 2>&1 | FileCheck %s
+
+struct B { void f(); };
+struct D1 : B {};
+struct D2 : B {};
+struct DD : D1, D2 {
+ void g() { f(); }
+ // Ensure that after line-wrapping takes place, we preserve artificial
+ // newlines introduced to manually format a section of the diagnostic text.
+ // CHECK: {{.*}}: error:
+ // CHECK: struct DD -> struct D1 -> struct B
+ // CHECK: struct DD -> struct D2 -> struct B
+}