[cfe-commits] r140538 - in /cfe/trunk: lib/Frontend/TextDiagnosticPrinter.cpp test/Misc/diag-line-wrapping.cpp
Chandler Carruth
chandlerc at gmail.com
Mon Sep 26 09:43:25 PDT 2011
Author: chandlerc
Date: Mon Sep 26 11:43:25 2011
New Revision: 140538
URL: http://llvm.org/viewvc/llvm-project?rev=140538&view=rev
Log:
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.
Added:
cfe/trunk/test/Misc/diag-line-wrapping.cpp
Modified:
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=140538&r1=140537&r2=140538&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Mon Sep 26 11:43:25 2011
@@ -1097,7 +1097,7 @@
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 @@
Wrapped = true;
}
+ // Append any remaning text from the message with its existing formatting.
+ OS << Str.substr(Length);
+
return Wrapped;
}
Added: cfe/trunk/test/Misc/diag-line-wrapping.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-line-wrapping.cpp?rev=140538&view=auto
==============================================================================
--- cfe/trunk/test/Misc/diag-line-wrapping.cpp (added)
+++ cfe/trunk/test/Misc/diag-line-wrapping.cpp Mon Sep 26 11:43:25 2011
@@ -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
+}
More information about the cfe-commits
mailing list