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_LOGDIAGNOSTICPRINTER_H
11 #define LLVM_CLANG_FRONTEND_LOGDIAGNOSTICPRINTER_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 Option Flag for the diagnostic
40 std::string WarningOption;
42 /// The level of the diagnostic.
43 DiagnosticsEngine::Level DiagnosticLevel;
46 void EmitDiagEntry(llvm::raw_ostream &OS,
47 const LogDiagnosticPrinter::DiagEntry &DE);
49 // Conditional ownership (when StreamOwner is non-null, it's keeping OS
50 // alive). We might want to replace this with a wrapper for conditional
51 // ownership eventually - it seems to pop up often enough.
53 std::unique_ptr<raw_ostream> StreamOwner;
54 const LangOptions *LangOpts;
55 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
57 SourceLocation LastWarningLoc;
58 FullSourceLoc LastLoc;
60 SmallVector<DiagEntry, 8> Entries;
62 std::string MainFilename;
63 std::string DwarfDebugFlags;
66 LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags,
67 std::unique_ptr<raw_ostream> StreamOwner);
69 void setDwarfDebugFlags(StringRef Value) {
70 DwarfDebugFlags = Value;
73 void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override {
77 void EndSourceFile() override;
79 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
80 const Diagnostic &Info) override;
83 } // end namespace clang