]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/TextDiagnosticPrinter.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / tools / clang / include / clang / Frontend / TextDiagnosticPrinter.h
1 //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
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 // This is a concrete diagnostic client, which prints the diagnostics to
11 // standard error.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
16 #define LLVM_CLANG_FRONTEND_TEXT_DIAGNOSTIC_PRINTER_H_
17
18 #include "clang/Basic/Diagnostic.h"
19 #include "clang/Basic/LLVM.h"
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include "llvm/ADT/OwningPtr.h"
22
23 namespace clang {
24 class DiagnosticOptions;
25 class LangOptions;
26 class TextDiagnostic;
27
28 class TextDiagnosticPrinter : public DiagnosticConsumer {
29   raw_ostream &OS;
30   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
31
32   /// \brief Handle to the currently active text diagnostic emitter.
33   OwningPtr<TextDiagnostic> TextDiag;
34
35   /// A string to prefix to error messages.
36   std::string Prefix;
37
38   unsigned OwnsOutputStream : 1;
39
40 public:
41   TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags,
42                         bool OwnsOutputStream = false);
43   virtual ~TextDiagnosticPrinter();
44
45   /// setPrefix - Set the diagnostic printer prefix string, which will be
46   /// printed at the start of any diagnostics. If empty, no prefix string is
47   /// used.
48   void setPrefix(std::string Value) { Prefix = Value; }
49
50   void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP);
51   void EndSourceFile();
52   void HandleDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info);
53 };
54
55 } // end namespace clang
56
57 #endif