switch TextDiagnosticPrinter to raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59597 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 4314180..ead8734 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -1443,7 +1443,8 @@
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.
diff --git a/include/clang/Driver/TextDiagnosticPrinter.h b/include/clang/Driver/TextDiagnosticPrinter.h
index e5ef9fc..e6d570c 100644
--- a/include/clang/Driver/TextDiagnosticPrinter.h
+++ b/include/clang/Driver/TextDiagnosticPrinter.h
@@ -17,7 +17,10 @@
#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 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);
diff --git a/lib/Driver/TextDiagnosticPrinter.cpp b/lib/Driver/TextDiagnosticPrinter.cpp
index cfbe8a7..b4be930 100644
--- a/lib/Driver/TextDiagnosticPrinter.cpp
+++ b/lib/Driver/TextDiagnosticPrinter.cpp
@@ -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 @@
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 @@
*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 @@
CaretLine.erase(CaretLine.end()-1);
// Emit what we have computed.
- OS << SourceLine << "\n";
- OS << CaretLine << "\n";
+ OS << SourceLine << '\n';
+ OS << CaretLine << '\n';
}
+
+ OS.flush();
}