1 //===--- LogDiagnosticPrinter.h - Log Diagnostic Client ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_LOG_DIAGNOSTIC_PRINTER_H_
11 #define LLVM_CLANG_FRONTEND_LOG_DIAGNOSTIC_PRINTER_H_
13 #include "clang/Basic/Diagnostic.h"
14 #include "clang/Basic/SourceLocation.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/StringRef.h"
19 class DiagnosticOptions;
22 class LogDiagnosticPrinter : public DiagnosticConsumer {
24 /// The primary message line of the diagnostic.
27 /// The source file name, if available.
30 /// The source file line number, if available.
33 /// The source file column number, if available.
36 /// The ID of the diagnostic.
37 unsigned DiagnosticID;
39 /// The level of the diagnostic.
40 DiagnosticsEngine::Level DiagnosticLevel;
43 void EmitDiagEntry(llvm::raw_ostream &OS,
44 const LogDiagnosticPrinter::DiagEntry &DE);
47 const LangOptions *LangOpts;
48 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
50 SourceLocation LastWarningLoc;
51 FullSourceLoc LastLoc;
52 unsigned OwnsOutputStream : 1;
54 SmallVector<DiagEntry, 8> Entries;
56 std::string MainFilename;
57 std::string DwarfDebugFlags;
60 LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags,
61 bool OwnsOutputStream = false);
62 virtual ~LogDiagnosticPrinter();
64 void setDwarfDebugFlags(StringRef Value) {
65 DwarfDebugFlags = Value;
68 void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override {
72 void EndSourceFile() override;
74 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
75 const Diagnostic &Info) override;
78 } // end namespace clang