clang  14.0.0git
TextDiagnosticPrinter.h
Go to the documentation of this file.
1 //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This is a concrete diagnostic client, which prints the diagnostics to
10 // standard error.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
15 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
16 
17 #include "clang/Basic/Diagnostic.h"
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include <memory>
21 
22 namespace clang {
23 class DiagnosticOptions;
24 class LangOptions;
25 class TextDiagnostic;
26 
28  raw_ostream &OS;
30 
31  /// Handle to the currently active text diagnostic emitter.
32  std::unique_ptr<TextDiagnostic> TextDiag;
33 
34  /// A string to prefix to error messages.
35  std::string Prefix;
36 
37  unsigned OwnsOutputStream : 1;
38 
39 public:
40  TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags,
41  bool OwnsOutputStream = false);
42  ~TextDiagnosticPrinter() override;
43 
44  /// setPrefix - Set the diagnostic printer prefix string, which will be
45  /// printed at the start of any diagnostics. If empty, no prefix string is
46  /// used.
47  void setPrefix(std::string Value) { Prefix = std::move(Value); }
48 
49  void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override;
50  void EndSourceFile() override;
52  const Diagnostic &Info) override;
53 };
54 
55 } // end namespace clang
56 
57 #endif
clang::DiagnosticsEngine::Level
Level
The level of the diagnostic, after it has been through mapping.
Definition: Diagnostic.h:194
clang::TextDiagnosticPrinter::HandleDiagnostic
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.
Definition: TextDiagnosticPrinter.cpp:109
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::TextDiagnosticPrinter::EndSourceFile
void EndSourceFile() override
Callback to inform the diagnostic client that processing of a source file has ended.
Definition: TextDiagnosticPrinter.cpp:42
clang::DiagnosticConsumer
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Definition: Diagnostic.h:1707
clang::TextDiagnosticPrinter::TextDiagnosticPrinter
TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags, bool OwnsOutputStream=false)
Definition: TextDiagnosticPrinter.cpp:24
clang::TextDiagnosticPrinter::setPrefix
void setPrefix(std::string Value)
setPrefix - Set the diagnostic printer prefix string, which will be printed at the start of any diagn...
Definition: TextDiagnosticPrinter.h:47
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1532
Diagnostic.h
clang::TextDiagnosticPrinter::~TextDiagnosticPrinter
~TextDiagnosticPrinter() override
Definition: TextDiagnosticPrinter.cpp:31
Value
Value
Definition: UninitializedValues.cpp:102
LLVM.h
clang::TextDiagnosticPrinter::BeginSourceFile
void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override
Callback to inform the diagnostic client that processing of a source file is beginning.
Definition: TextDiagnosticPrinter.cpp:36
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang
Definition: CalledOnceCheck.h:17
clang::prec::Level
Level
Definition: OperatorPrecedence.h:26
clang::TextDiagnosticPrinter
Definition: TextDiagnosticPrinter.h:27
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:130
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:47
clang::DiagnosticOptions
Options for controlling the compiler diagnostics engine.
Definition: DiagnosticOptions.h:70