From b8bf65e342d0872222f7ac10007d2837d7df437f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 30 Jan 2009 17:41:53 +0000 Subject: [PATCH] " Attached is a patch for TextDiagnosticPrinter that adds an optional parameter that allows users to omit the printing of the source location on a diagnostic. So basically it would omit the "abc.c:5:1: " at the beginning of the line." Patch by Alexei Svitkine! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63396 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/TextDiagnosticPrinter.h | 6 ++++-- lib/Driver/TextDiagnosticPrinter.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/clang/Driver/TextDiagnosticPrinter.h b/include/clang/Driver/TextDiagnosticPrinter.h index b49094dcb1..972fe6d8bc 100644 --- a/include/clang/Driver/TextDiagnosticPrinter.h +++ b/include/clang/Driver/TextDiagnosticPrinter.h @@ -31,10 +31,12 @@ class TextDiagnosticPrinter : public DiagnosticClient { llvm::raw_ostream &OS; bool ShowColumn; bool CaretDiagnostics; + bool ShowLocation; public: TextDiagnosticPrinter(llvm::raw_ostream &os, bool showColumn = true, - bool caretDiagnistics = true) - : OS(os), ShowColumn(showColumn), CaretDiagnostics(caretDiagnistics) {} + bool caretDiagnistics = true, bool showLocation = true) + : OS(os), ShowColumn(showColumn), CaretDiagnostics(caretDiagnistics), + ShowLocation(showLocation) {} void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM); diff --git a/lib/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp index 36e2d28d2e..27353b8344 100644 --- a/lib/Driver/TextDiagnosticPrinter.cpp +++ b/lib/Driver/TextDiagnosticPrinter.cpp @@ -113,10 +113,12 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, // Compute the column number. ColNo = PLoc.getColumn(); - OS << PLoc.getFilename() << ':' << LineNo << ':'; - if (ColNo && ShowColumn) - OS << ColNo << ':'; - OS << ' '; + if (ShowLocation) { + OS << PLoc.getFilename() << ':' << LineNo << ':'; + if (ColNo && ShowColumn) + OS << ColNo << ':'; + OS << ' '; + } } switch (Level) { -- 2.50.1