// to produce easily machine parsable output. Add a space before the
// source line and the caret to make it trivial to tell the main diagnostic
// line from what the user is intended to see.
- if (DiagOpts->ShowSourceRanges) {
+ if (DiagOpts->ShowSourceRanges && !SourceLine.empty()) {
SourceLine = ' ' + SourceLine;
CaretLine = ' ' + CaretLine;
}
void TextDiagnostic::emitSnippet(StringRef SourceLine,
unsigned MaxLineNoDisplayWidth,
unsigned LineNo) {
- if (SourceLine.empty())
- return;
-
// Emit line number.
if (MaxLineNoDisplayWidth > 0) {
unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo);
--- /dev/null
+// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
+
+/// empty lines in multi-line diagnostic snippets are preserved.
+static_assert(false &&
+
+ true, "");
+// CHECK: static assertion failed
+// CHECK-NEXT: {{^}} 4 | static_assert(false &&{{$}}
+// CHECK-NEXT: {{^}} | ^~~~~~~~{{$}}
+// CHECK-NEXT: {{^}} 5 | {{$}}
+// CHECK-NEXT: {{^}} 6 | true, "");{{$}}
+// CHECK-NEXT: {{^}} | ~~~~{{$}}