[cfe-commits] r70337 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp

Chris Lattner sabre at nondot.org
Tue Apr 28 15:33:17 PDT 2009


Author: lattner
Date: Tue Apr 28 17:33:16 2009
New Revision: 70337

URL: http://llvm.org/viewvc/llvm-project?rev=70337&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=70337&r1=70336&r2=70337&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Tue Apr 28 17:33:16 2009
@@ -209,6 +209,16 @@
   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 @@
       }
     }
 
-    if (!InsertionLine.empty())
+    if (!InsertionLine.empty()) {
+      if (PrintRangeInfo) 
+        OS << ' ';
       OS << InsertionLine << '\n';
+    }
   }
 }
 





More information about the cfe-commits mailing list