summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/TextDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-28 22:33:16 +0000
committerChris Lattner <sabre@nondot.org>2009-04-28 22:33:16 +0000
commitaf6094eafce2a989bc2850c32b5cf50b593ebd76 (patch)
tree65d3168e612def06a9d285721cf478340cc68811 /clang/lib/Frontend/TextDiagnosticPrinter.cpp
parent869292d5b6394e5dbc0e66c7f86705fb1acbc4bb (diff)
downloadbcm5719-llvm-af6094eafce2a989bc2850c32b5cf50b593ebd76.tar.gz
bcm5719-llvm-af6094eafce2a989bc2850c32b5cf50b593ebd76.zip
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. llvm-svn: 70337
Diffstat (limited to 'clang/lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r--clang/lib/Frontend/TextDiagnosticPrinter.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
index be69b760fa3..df9b62433a0 100644
--- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/clang/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';
+ }
}
}
OpenPOWER on IntegriCloud