forked from OSchip/llvm-project
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. llvm-svn: 140538
This commit is contained in:
parent
55f340eb62
commit
374eaa9c4e
|
@ -1097,7 +1097,7 @@ static bool printWordWrapped(raw_ostream &OS, StringRef Str,
|
||||||
unsigned Columns,
|
unsigned Columns,
|
||||||
unsigned Column = 0,
|
unsigned Column = 0,
|
||||||
unsigned Indentation = WordWrapIndentation) {
|
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.
|
// The string used to indent each line.
|
||||||
llvm::SmallString<16> IndentStr;
|
llvm::SmallString<16> IndentStr;
|
||||||
|
@ -1135,6 +1135,9 @@ static bool printWordWrapped(raw_ostream &OS, StringRef Str,
|
||||||
Wrapped = true;
|
Wrapped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Append any remaning text from the message with its existing formatting.
|
||||||
|
OS << Str.substr(Length);
|
||||||
|
|
||||||
return Wrapped;
|
return Wrapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue