blob: f148d5e6a26c414a51d1efae71016a9e121f7593 [file] [log] [blame]
Daniel Dunbar9df23492011-04-07 18:31:10 +00001//===--- LogDiagnosticPrinter.cpp - Log Diagnostic Printer ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/Frontend/LogDiagnosticPrinter.h"
11#include "llvm/ADT/SmallString.h"
12#include "llvm/Support/raw_ostream.h"
13using namespace clang;
14
15LogDiagnosticPrinter::LogDiagnosticPrinter(llvm::raw_ostream &os,
16 const DiagnosticOptions &diags,
17 bool _OwnsOutputStream)
18 : OS(os), LangOpts(0), DiagOpts(&diags),
19 OwnsOutputStream(_OwnsOutputStream) {
20}
21
22LogDiagnosticPrinter::~LogDiagnosticPrinter() {
23 if (OwnsOutputStream)
24 delete &OS;
25}
26
27void LogDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
28 const DiagnosticInfo &Info) {
29 // Default implementation (Warnings/errors count).
30 DiagnosticClient::HandleDiagnostic(Level, Info);
31
32 // Write to a temporary string to ensure atomic write of diagnostic object.
33 llvm::SmallString<512> Msg;
34 llvm::raw_svector_ostream OS(Msg);
35
36 OS << "hello!\n";
37
38 this->OS << OS.str();
39}