]> granicus.if.org Git - clang/commitdiff
switch TextDiagnosticPrinter to raw_ostream.
authorChris Lattner <sabre@nondot.org>
Wed, 19 Nov 2008 06:56:25 +0000 (06:56 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 19 Nov 2008 06:56:25 +0000 (06:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59597 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp
include/clang/Driver/TextDiagnosticPrinter.h
lib/Driver/TextDiagnosticPrinter.cpp

index 4314180c45e752a386dd6abbeb341499f1f93068..ead873447bc50aba28858116b1a9359e1fa37694 100644 (file)
@@ -1443,7 +1443,8 @@ int main(int argc, char **argv) {
   
   if (!VerifyDiagnostics) {
     // Print diagnostics to stderr by default.
-    TextDiagClient = new TextDiagnosticPrinter(!NoShowColumn,
+    TextDiagClient = new TextDiagnosticPrinter(llvm::errs(),
+                                               !NoShowColumn,
                                                !NoCaretDiagnostics);
   } else {
     // When checking diagnostics, just buffer them up.
index e5ef9fca824b27f440f6155307b3a5938eed96e1..e6d570c5e3b7de9a62cb59482337c5c30c19ce06 100644 (file)
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
-#include "llvm/Support/Streams.h"
+
+namespace llvm {
+  class raw_ostream;
+}
 
 namespace clang {
 class SourceManager;
@@ -25,12 +28,12 @@ class SourceManager;
 class TextDiagnosticPrinter : public DiagnosticClient {
   FullSourceLoc LastWarningLoc;
   FullSourceLoc LastLoc;
-  llvm::OStream OS;
+  llvm::raw_ostream &OS;
   bool ShowColumn;
   bool CaretDiagnostics;
 public:
-  TextDiagnosticPrinter(bool showColumn = true, bool caretDiagnistics = true,
-      llvm::OStream &os = llvm::cerr)
+  TextDiagnosticPrinter(llvm::raw_ostream &os, bool showColumn = true,
+                        bool caretDiagnistics = true)
     : OS(os), ShowColumn(showColumn), CaretDiagnostics(caretDiagnistics) {}
 
   void PrintIncludeStack(FullSourceLoc Pos);
index cfbe8a7f927df89c987cc4e84f5e26de9557de96..b4be9307ea73d0d6ed7fa59826399d812060a6db 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/Driver/TextDiagnosticPrinter.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/ADT/SmallString.h"
 using namespace clang;
@@ -29,7 +30,7 @@ PrintIncludeStack(FullSourceLoc Pos) {
   unsigned LineNo = Pos.getLineNumber();
   
   OS << "In file included from " << Pos.getSourceName()
-     << ":" << LineNo << ":\n";
+     << ':' << LineNo << ":\n";
 }
 
 /// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s)
@@ -127,10 +128,10 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
            *LineEnd != '\n' && *LineEnd != '\r')
       ++LineEnd;
   
-    OS << Buffer->getBufferIdentifier() << ":" << LineNo << ":";
+    OS << Buffer->getBufferIdentifier() << ':' << LineNo << ':';
     if (ColNo && ShowColumn) 
-      OS << ColNo << ":";
-    OS << " ";
+      OS << ColNo << ':';
+    OS << ' ';
   }
   
   switch (Level) {
@@ -193,7 +194,9 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
       CaretLine.erase(CaretLine.end()-1);
     
     // Emit what we have computed.
-    OS << SourceLine << "\n";
-    OS << CaretLine << "\n";
+    OS << SourceLine << '\n';
+    OS << CaretLine << '\n';
   }
+  
+  OS.flush();
 }