diff options
Diffstat (limited to 'lib/Frontend/LogDiagnosticPrinter.cpp')
-rw-r--r-- | lib/Frontend/LogDiagnosticPrinter.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/Frontend/LogDiagnosticPrinter.cpp b/lib/Frontend/LogDiagnosticPrinter.cpp new file mode 100644 index 0000000000..f148d5e6a2 --- /dev/null +++ b/lib/Frontend/LogDiagnosticPrinter.cpp @@ -0,0 +1,39 @@ +//===--- LogDiagnosticPrinter.cpp - Log Diagnostic Printer ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Frontend/LogDiagnosticPrinter.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/raw_ostream.h" +using namespace clang; + +LogDiagnosticPrinter::LogDiagnosticPrinter(llvm::raw_ostream &os, + const DiagnosticOptions &diags, + bool _OwnsOutputStream) + : OS(os), LangOpts(0), DiagOpts(&diags), + OwnsOutputStream(_OwnsOutputStream) { +} + +LogDiagnosticPrinter::~LogDiagnosticPrinter() { + if (OwnsOutputStream) + delete &OS; +} + +void LogDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, + const DiagnosticInfo &Info) { + // Default implementation (Warnings/errors count). + DiagnosticClient::HandleDiagnostic(Level, Info); + + // Write to a temporary string to ensure atomic write of diagnostic object. + llvm::SmallString<512> Msg; + llvm::raw_svector_ostream OS(Msg); + + OS << "hello!\n"; + + this->OS << OS.str(); +} |