aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/LogDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-04-07 18:31:10 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-04-07 18:31:10 +0000
commit9df23493f5b8a223dfbc491e4b7de3850797c2e7 (patch)
tree3077ef2982a6a1c484addba86aee07dd06d79cd0 /lib/Frontend/LogDiagnosticPrinter.cpp
parentb680d4bc53ecfece9b583f8e8566fddb5189d39a (diff)
Frontend: Sketch a LogDiagnosticPrinter object, and wire CC_LOG_DIAGNOSTICS to
it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/LogDiagnosticPrinter.cpp')
-rw-r--r--lib/Frontend/LogDiagnosticPrinter.cpp39
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();
+}