]> granicus.if.org Git - clang/commitdiff
" Attached is a patch for TextDiagnosticPrinter that adds an optional
authorChris Lattner <sabre@nondot.org>
Fri, 30 Jan 2009 17:41:53 +0000 (17:41 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 30 Jan 2009 17:41:53 +0000 (17:41 +0000)
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
lib/Driver/TextDiagnosticPrinter.cpp

index b49094dcb1e9f9d1f903a2811a7dd2c57d3dd2a2..972fe6d8bc2611c0aae442ccbe614e8244c5e5d6 100644 (file)
@@ -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);
 
index 36e2d28d2e33b128fcfd3e4e800415eb917fe50f..27353b83443e47c2c3898a8e74264866c0ac712d 100644 (file)
@@ -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) {