clang  6.0.0svn
TextDiagnosticPrinter.h
Go to the documentation of this file.
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_TEXTDIAGNOSTICPRINTER_H
16 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
17 
18 #include "clang/Basic/Diagnostic.h"
19 #include "clang/Basic/LLVM.h"
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
21 #include <memory>
22 
23 namespace clang {
24 class DiagnosticOptions;
25 class LangOptions;
26 class TextDiagnostic;
27 
29  raw_ostream &OS;
31 
32  /// \brief Handle to the currently active text diagnostic emitter.
33  std::unique_ptr<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  ~TextDiagnosticPrinter() override;
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 = std::move(Value); }
49 
50  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override;
51  void EndSourceFile() override;
53  const Diagnostic &Info) override;
54 };
55 
56 } // end namespace clang
57 
58 #endif
void setPrefix(std::string Value)
setPrefix - Set the diagnostic printer prefix string, which will be printed at the start of any diagn...
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Definition: Diagnostic.h:1395
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override
Callback to inform the diagnostic client that processing of a source file is beginning.
Defines the Diagnostic-related interfaces.
void HandleDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info) override
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
void EndSourceFile() override
Callback to inform the diagnostic client that processing of a source file has ended.
Options for controlling the compiler diagnostics engine.
TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags, bool OwnsOutputStream=false)
Dataflow Directional Tag Classes.
Level
The level of the diagnostic, after it has been through mapping.
Definition: Diagnostic.h:150
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1225
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:98