From 770dbf04b4e56a2aa0901b7515318cf9e59adf2a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 28 Apr 2009 22:33:16 +0000 Subject: [PATCH] In -fdiagnostics-print-source-range-info mode, print a space before the lines that clang extracts from the source code so that machine parsing can easily ignore them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70337 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/TextDiagnosticPrinter.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index be69b760fa..df9b62433a 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -209,6 +209,16 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, while (CaretLine[CaretLine.size()-1] == ' ') CaretLine.erase(CaretLine.end()-1); + // If we are in -fdiagnostics-print-source-range-info mode, we are trying 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 (PrintRangeInfo) { + SourceLine = ' ' + SourceLine; + CaretLine = ' ' + CaretLine; + } + + // Emit what we have computed. OS << SourceLine << '\n'; OS << CaretLine << '\n'; @@ -238,8 +248,11 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, } } - if (!InsertionLine.empty()) + if (!InsertionLine.empty()) { + if (PrintRangeInfo) + OS << ' '; OS << InsertionLine << '\n'; + } } } -- 2.40.0