1193326Sed//===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
2193326Sed//
3193326Sed//                     The LLVM Compiler Infrastructure
4193326Sed//
5193326Sed// This file is distributed under the University of Illinois Open Source
6193326Sed// License. See LICENSE.TXT for details.
7193326Sed//
8193326Sed//===----------------------------------------------------------------------===//
9193326Sed//
10193326Sed// This is a concrete diagnostic client, which prints the diagnostics to
11193326Sed// standard error.
12193326Sed//
13193326Sed//===----------------------------------------------------------------------===//
14193326Sed
15280031Sdim#ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
16280031Sdim#define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
17193326Sed
18193326Sed#include "clang/Basic/Diagnostic.h"
19234353Sdim#include "clang/Basic/LLVM.h"
20249423Sdim#include "llvm/ADT/IntrusiveRefCntPtr.h"
21276479Sdim#include <memory>
22193326Sed
23193326Sednamespace clang {
24198893Srdivackyclass DiagnosticOptions;
25198893Srdivackyclass LangOptions;
26234353Sdimclass TextDiagnostic;
27193326Sed
28226633Sdimclass TextDiagnosticPrinter : public DiagnosticConsumer {
29226633Sdim  raw_ostream &OS;
30249423Sdim  IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
31198893Srdivacky
32234353Sdim  /// \brief Handle to the currently active text diagnostic emitter.
33276479Sdim  std::unique_ptr<TextDiagnostic> TextDiag;
34193326Sed
35204643Srdivacky  /// A string to prefix to error messages.
36204643Srdivacky  std::string Prefix;
37204643Srdivacky
38234353Sdim  unsigned OwnsOutputStream : 1;
39234353Sdim
40193326Sedpublic:
41243830Sdim  TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags,
42199482Srdivacky                        bool OwnsOutputStream = false);
43288943Sdim  ~TextDiagnosticPrinter() override;
44193326Sed
45204643Srdivacky  /// setPrefix - Set the diagnostic printer prefix string, which will be
46204643Srdivacky  /// printed at the start of any diagnostics. If empty, no prefix string is
47204643Srdivacky  /// used.
48204643Srdivacky  void setPrefix(std::string Value) { Prefix = Value; }
49204643Srdivacky
50276479Sdim  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override;
51276479Sdim  void EndSourceFile() override;
52276479Sdim  void HandleDiagnostic(DiagnosticsEngine::Level Level,
53276479Sdim                        const Diagnostic &Info) override;
54193326Sed};
55193326Sed
56207632Srdivacky} // end namespace clang
57193326Sed
58193326Sed#endif
59